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