Re: Moving /tmp to tmpfs makes it useless
- To: firstname.lastname@example.org
- Subject: Re: Moving /tmp to tmpfs makes it useless
- From: Uoti Urpala <email@example.com>
- Date: Tue, 05 Jun 2012 15:41:30 +0300
- Message-id: <firstname.lastname@example.org>
- In-reply-to: <email@example.com>
Goswin von Brederlow wrote:
> Uoti Urpala <firstname.lastname@example.org> writes:
> > I haven't read the relevant kernel code, but that doesn't match the
> > behavior I see. Reading a large file from tmpfs and then allocating
> > memory results in large swap writes every time, even if the newly
> > allocated memory is not itself immediately swapped out and the file
> > should already be in swap from before.
> But does it rewrite the pages it has just read back? Or does it swap out
> some other pages it didn't have swapped out before?
> It might consider a page it just had to swap in to be more valuable than
> a page it had lying around for a long time and rather swap out the old
> page than forget the just read page. So this doesn't proof that data in
> tmpfs is rewritten again and again.
There shouldn't be gigabytes of "other pages" to write. The set of
changing pages in memory that would always differ from what has already
been written to swap shouldn't be that large.
> > The script below can be used to test the behavior. It creates a file,
> > then loops alternatively reading the file and allocating+freeing memory.
> > It's noteworthy that sometimes the read performance also drops over
> > iterations (maybe the swap layout becomes more fragmented?). I used the
> > given sizes for testing on a machine with 8 GiB memory. This load does
> > run faster on ext4 than tmpfs.
> What kernel?
I initially tested it on some older kernel; retried on 3.3.
Did you not try the script yourself if you expected different results?
If you did test, what results did you get?