Gentoo Archives: gentoo-amd64

From: Richard Freeman <rich0@g.o>
To: gentoo-amd64@l.g.o
Subject: Re: [gentoo-amd64] Re: tmpfs help
Date: Wed, 13 Feb 2008 15:27:09
Message-Id: 47B30C3D.2080204@gentoo.org
In Reply to: Re: [gentoo-amd64] Re: tmpfs help by Volker Armin Hemmann
1 Volker Armin Hemmann wrote:
2 > On Mittwoch, 13. Februar 2008, Duncan wrote:
3 >>> removed lots of irrelevant 'my hardware is so cool' stuff'.
4 >
5 > You forget some (little) things. Not everything can be swapped out.
6
7 How is this relevant? Some memory is locked or effectively locked.
8 That limits buffers/cache in the disk-based fs case, and swap in the
9 tmpfs case. I don't see that there is much of a difference.
10
11 > Swap is
12 > extremly slow AND it is much worse to swapout/swapin programm code that
13 > should be run, instead of fetching some files from disk while the programm
14 > runs.
15
16 You keep asserting this. Why should fetching a page from swap be slower
17 than fetching the equivalent space from a file? In fact, if mmap is
18 used to read a file the same code probably is used for both.
19
20 And the kernel is not likely to swap out recently-run program pages. It
21 isn't going to keep a bunch of compiled binaries in memory for 10
22 minutes while it swaps in and out the compiler - it would swap in and
23 out source files and binary files - just as with a disk-based
24 filesystem. If for some reason part of the compiler is swapped out, it
25 would be rewritten to disk every time it got swapped out - only the
26 first time. I'm sure the kernel would notice that the pages were never
27 written since the last swap and would just flush them from memory
28 without another write. However, this should still only happen on idle
29 pages, and swapping those out is probably better than any other use of
30 memory (and those pages would get swapped out even with a disk-based
31 filesystem in use).
32
33 I'm of course interested in benchmarks. In theory swap should be faster
34 than files. However, implementation does matter and maybe there is some
35 flaw that makes things slower. My assertion is that a swap-based
36 solution gives the kernel more freedom to optimize memory use than a
37 disk-based solution. So, this should be a fundamentally-superior solution.
38 --
39 gentoo-amd64@l.g.o mailing list