Gentoo Archives: gentoo-user

From: Grant <emailgrant@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] mysqld invoked oom-killer
Date: Fri, 22 Jul 2011 19:05:07
Message-Id: CAN0CFw0i+EWb_CTuscPsOYj4V1x_ptW5NbWB7ODBVNQJ==-sAw@mail.gmail.com
In Reply to: Re: [gentoo-user] mysqld invoked oom-killer by Albert Hopkins
1 >> >> Then why not have a really big swap file?  If swap is useful as a
2 >> >> second layer of caching behind RAM, why doesn't everyone with some
3 >> >> extra hard drive space have a 100GB swap file?
4 >> >>
5 >> > You've not understood what I said, I think.  Swap is not useful as
6 >> > filesystem cache.  Swap is as efficient (probably a little less)
7 >> than
8 >> > the files on the disk.  It's RAM that's efficient as filesystem
9 >> 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 > Because you're (likely) never going to be using 100GB of memory at one
20 > time for all your processes, let alone "idle" processes, so what's the
21 > point of allocating all that swap?
22 >
23 > Continuing the analogy, it's like getting a stadium-sized attic that's
24 > 100x bigger than the house your building it on just to store a Christmas
25 > tree and a few other items.
26 >
27 > Here's another way of looking at it.  The kernel wants to use *all* your
28 > RAM.  RAM is fast (compared to disk).  But it wants to use the RAM for
29 > stuff that's actually needed most at the present time. So say you have
30 > 4G RAM.  You're only using maybe 1.5G memory for applications.  So the
31 > kernel is going to try to use the remaining 2.5G for cache when/if it
32 > needs to.  But let's say you're hitting the disk a lot because you're
33 > compiling something, then the kernel might decide it would like to cache
34 > more files than the 2.5G.  So it sees you have 300M of paged in process
35 > memory that hasn't been used in a long while.  A better use of RAM may
36 > be to swap out those 300M and use it for more filesystem cache, causing
37 > your compilation to run faster.  But if you have a 100G swap file and
38 > only 300M of "idle" pages then all that extra swap isn't going to be of
39 > any use.  Similarly, you don't want to swap out all of the 1.5G RAM
40 > because some of it is actually being actively used (e.g. by the
41 > compiler).
42
43 That all makes perfect sense. So the reason a swap larger than maybe
44 1GB is not usually implemented is because idle processes don't
45 normally have more than a few hundred MB of pages in memory?
46
47 Wouldn't a sufficiently large swap (100GB for example) completely
48 prevent out of memory conditions and the oom-killer?
49
50 - Grant

Replies

Subject Author
Re: [gentoo-user] mysqld invoked oom-killer Peter Humphrey <peter@××××××××××××××.org>
Re: [gentoo-user] mysqld invoked oom-killer Albert Hopkins <marduk@×××××××××××.org>
[gentoo-user] Re: mysqld invoked oom-killer walt <w41ter@×××××.com>