[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Default size limits for /run (/var/run) and /run/lock (/var/lock)

On Wed, 13 Apr 2011 13:34:13 +0200, "Bernhard R. Link" <brlink@debian.org> wrote:
> * Philip Hands <phil@hands.com> [110413 12:54]:
> > This strikes me as suboptimal, since one could use the disk space
> > allocated to /tmp as extra swap and then allocate a tmpfs of that size
> > to be mounted on /tmp with no effect other than allowing the system to
> > have access to more swap than it would have otherwise had (of course,
> > that's probably more than it needs, so instead you could just save some
> > disk space that would otherwise be left generally unused by overloading
> > the swap usage with /tmp usage.
> >
> > Therefore, in the multi-partition setup, I think we should also default
> > to having /tmp on tmpfs.
> This has both the disadvantage of a system then having swap (given the
> big memory sizes one currently has and the big difference between RAM
> and disk access times, having swap is often quite a disadvantage) and

Are you suggesting that a system that has enough RAM to not need swap
will become slower if you enable swap but don't use it?

If not, then either the files in /tmp will sit in RAM and therefore be a
lot faster, or if they need to go to disk, will have been staged via
swap, which may well allow a lot of small writes to small files to be
coalesced into larger swap writes, although I'm not familiar enough with
that to compare the amount of disk activity provoked by writing a lot of
small files onto an ext3 file system vs. taking the most elderly data
From a tmpfs and deciding to swap it out.

I can imagine that, for instance, removing a large file from /tmp when
on a file system might well require several writes, whereas it seems
possible that doing the same for a swapped out tmpfs might be a case of
simply recording that the blocks are ready for reuse.  On the other
hand, it may be that one needs to read in each and every block in order
to mark it ad being deleted, but I would hope that's not the way it works.

> of mixing several different things (/tmp is usually something simply
> filling over time,

Really?  Checking a couple of servers at random, one that's been running
for about 8 months but is fairly tightly locked down, has 8Kb used, and
another that's got rather more random stuff running on it, it has 17Mb
in /tmp, and that turns out to be debris laying around after a process
that does OCR on postfix files while scanning for SPAM -- so that's
actually a bug by the looks of it.

Even on servers where it is the case that /tmp grows over time, it
strikes me that tmpfs gives the system a much better chance to make
sensible decisions about when to write data out to disk.

On a mounted file system the system will attempt to ensure that the data
gets out to disk in a reasonably timely manner, since it's trying to
ensure that it's not lost in the event of a crash -- in that case of
/tmp, any effort to keep the normal file-system promise of post-crash
integrity is wasted effort, since we're going to throw the data away

With tmpfs on the other hand, the data will never hit the disk if there
is enough RAM, and if there is a need to write it out, it'll generally
write the oldest data out first, so the portions of the tmpfs that are
being used for short-lived files will generally not be written before
those files are deleted again, so that they never need to be written at

> so without low enough limits one risks that something
> important is sometime not working because of missing RAM).

If you'd read what I wrote, I suggested that a reasonable start would be
to allocate the /tmp filesystem space as swap, and then limit /tmp to
that size -- even if you then fill /tmp it cannot exceed the extra size
that you allocated to swap by giving it the disk that you'd otherwise be
using for /tmp as a file system.

Admittedly, I think that using the amount the we currently allocate to
/tmp for swap would be a waste, but it's a reasonable starting point.

In fact, it wouldn't surprise me if the act of mounting an additional
filesystem consumes more memory than a tmpfs with 8kb of files on it, so
for the first server mentioned above I may well be consuming less RAM
than I would be mounting an empty /tmp from the disk.

Cheers, Phil.
|)|  Philip Hands [+44 (0)20 8530 9560]    http://www.hands.com/
|-|  HANDS.COM Ltd.                    http://www.uk.debian.org/
|(|  10 Onslow Gardens, South Woodford, London  E18 1NE  ENGLAND

Attachment: pgpjiN_2i4Gna.pgp
Description: PGP signature

Reply to: