Gentoo Archives: gentoo-user

From: Dale <rdalek1967@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] mysqld invoked oom-killer
Date: Fri, 22 Jul 2011 06:04:32
Message-Id: 4E290D20.7030701@gmail.com
In Reply to: Re: [gentoo-user] mysqld invoked oom-killer by Grant
1 Grant wrote:
2 >>> Then why not have a really big swap file? If swap is useful as a
3 >>> second layer of caching behind RAM, why doesn't everyone with some
4 >>> extra hard drive space have a 100GB swap file?
5 >>>
6 >>>
7 >> You've not understood what I said, I think. Swap is not useful as
8 >> filesystem cache. Swap is as efficient (probably a little less) than
9 >> the files on the disk. It's RAM that's efficient as filesystem cache.
10 >>
11 >> Where swap comes in is the kernel can swap out pages from "stale"
12 >> processes, and reclaim the RAM as filesystem cache.
13 >>
14 > That all makes perfect sense, but if a small swap is good and a large
15 > swap is not any better, I'm missing something. Maybe the pages from
16 > stale processes never total more than a small amount? I don't see how
17 > that could be.
18 >
19 > - Grant
20 >
21 >
22
23 To confuse you even more, there is a swappiness setting as well. On my
24 old x86 rig, I have 2Gbs of ram. My hard drive is really slow since it
25 is IDE. I set swappiness to 20. That tells the kernel that I have swap
26 space but don't use it unless you must. For what I use the rig for,
27 2Gbs is plenty of ram. The lower the swappiness setting, the less the
28 kernel will try to use ram. The higher the setting, the more it will
29 try to use swap.
30
31 I have a new rig that is amd64 and has SATA drives which are pretty
32 fast. I still have swappiness set to 20. Why do I have it set to 20
33 when the drives are faster you ask? I have it set to 20 because I have
34 16Gbs of ram here. Even if I have portage's work directory on tmpfs and
35 am compiling OOo, it should not need swap then either.
36
37 By the way, my swap partition is 1Gb on both systems. Why have it this
38 way since one machine has 2Gbs and one has 16Gbs? As it has been said,
39 you want a little swap and even using a little swap is OK. You just
40 don't want it to be using swap and actually swapping data all the time.
41 On my old rig, it started out with 512Mbs. I use KDE and it got to the
42 point where it was using enough ram that it was not just using swap and
43 letting things sit, it was actively swapping data from swap and doing so
44 a lot. It would only be using a 100Mbs sometimes 200Mbs. The point is,
45 it was slowing the system down because of the swapping process. I
46 bought a stick of ram and all was well again. It would still use a
47 100Mbs of swap at times but it would not be actively swapping the data
48 back and forth so it wasn't a big deal.
49
50 I think the point is this, it is good to have a little swap. It is even
51 OK for it to use a little swap when it is mostly sitting there. When
52 you notice it using swap and it is actively swapping and moving things
53 back and forth, you need more memory. Having the swap may can save you
54 from a crash but is can also give you a "time to add more ram" hint
55 too. If Linux starts using swap a good bit, you need more ram.
56
57 I do like that attic analogy tho. You may not mind going up in the
58 attic and dragging the tree down once a year but you may not want to go
59 to the attic to get a glass of water. That would put a lot of wear on
60 the stairs and it would also get old after a while to.
61
62 Dale
63
64 :-) :-)

Replies

Subject Author
Re: [gentoo-user] mysqld invoked oom-killer Dale <rdalek1967@×××××.com>
Re: [gentoo-user] mysqld invoked oom-killer Grant <emailgrant@×××××.com>