From: "Kerin Millar" <kfm@plushkava.net>
To: Slavko <linux@slavino.sk>, "netfilter ML" <netfilter@vger.kernel.org>
Subject: Re: Sets update
Date: Sun, 21 Jul 2024 16:46:56 +0100 [thread overview]
Message-ID: <5f5f7d91-d370-40d3-92bd-9ab5fa0c1135@app.fastmail.com> (raw)
In-Reply-To: <9C0711C5-60F3-4A5C-A441-85EAFEC8592A@slavino.sk>
On Sun, 21 Jul 2024, at 3:38 PM, Slavko wrote:
> Hi,
>
> Dňa 21. júla 2024 12:29:44 UTC používateľ Kerin Millar
> <kfm@plushkava.net> napísal:
>
>>You have a point. If on a severely RAM-constrained system, you may prefer to avoid the use of asynchronous pipelines and generate temporary files instead. Doing so would minimise RAM consumption.
>
> Correct me, if i am wrong, please...
>
> AFAIK memory is not problem in pipes. Yes, any pipe consumes some
> memory, but AFAIK it is somewhat limited (i don't know exact numbers)
> and if full, the writing process is paused, thus stops to produce more
> output, and thus not consumes more memory.
Yes, the default size of a pipe buffer is just 16 pages in Linux. However, one must also take into account that pipelines are fundamentally asynchronous. That is, all of the commands that comprise a shell pipeline are executed at approximately the same time and run in parallel to one another. In that particular respect, there is a potential bearing on memory consumption. I must emphasise that I am definitely not trying to discourage the use of pipelines - far from it! I only brought it up because I had the impression that you might be contending with a system that is severely short on RAM, in which case running programs serially can be helpful as a deliberate memory-saving measure.
>
> On other side, nowadays linux systems uses tmpfs for /tmp, thus storing
> output in temp file can be even worse (in mean of RAM) than using pipes,
> as whole output is in that file. Storing temporary file on disk is possible too,
> but doing that too often can drain Flash's lifetime, as modern Flash storage
> are really limited in that (in comparison with magnetic disks). IIRC the disk
> was used for pipes in old Unixes...
It depends on the exact circumstances but yes, it could easily be worse. If you have a mktemp(1) utility, it is probable that it responds to the TMPDIR variable, in which case you are free to point it to something other than a tmpfs-backed filesystem such as /var/tmp.
>
> But yes, without temp file, one cannot produce the same IP list multiple
> times (reading it into variable is the same), but at least second temp file
> have to be avoided...
It is not quite the same but I understand your point. Assuming that TMPDIR is backed by a tmpfs, both cases would result in non-disk-backed pages being allocated that may later be paged out to a swap - if any - under sufficient memory pressure.
--
Kerin Millar
next prev parent reply other threads:[~2024-07-21 15:47 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-21 7:44 Sets update Slavko
2024-07-21 9:58 ` Kerin Millar
2024-07-21 10:04 ` Kerin Millar
2024-07-21 11:23 ` Slavko
2024-07-21 12:29 ` Kerin Millar
2024-07-21 14:38 ` Slavko
2024-07-21 15:46 ` Kerin Millar [this message]
2024-07-23 7:24 ` Slavko
2024-07-23 7:37 ` Slavko
2024-07-23 9:39 ` Pablo Neira Ayuso
2024-07-23 10:23 ` Slavko
2024-07-23 11:32 ` Kerin Millar
2024-07-23 12:19 ` Pablo Neira Ayuso
2024-07-21 16:09 ` Eric
2024-07-21 16:46 ` Kerin Millar
2024-07-21 17:58 ` Slavko
2024-07-22 20:36 ` Pablo Neira Ayuso
2024-07-23 7:26 ` Slavko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5f5f7d91-d370-40d3-92bd-9ab5fa0c1135@app.fastmail.com \
--to=kfm@plushkava.net \
--cc=linux@slavino.sk \
--cc=netfilter@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox