Swap, Swapiness and Standby: swapping starts when waking up

Posted by mdo on Ask Ubuntu See other posts from Ask Ubuntu or by mdo
Published on 2012-11-04T11:20:55Z Indexed on 2012/11/04 11:23 UTC
Read the original article Hit count: 393

Filed under:
|
|

I'm running running Ubuntu 12.04 on a Lenovo W500 (Core2Duo T9400, 4GB Ram)

Current kernel: 3.2.0-32-generic #51-Ubuntu SMP Wed Sep 26 21:33:09 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux -- but the problems exists since a couple of months, surviving quite a few software (includig kernel) updates

I regularly put my machine into suspend-to-ram (S3) and when the machine comes back up Ubuntu starts to swap out processes. I was able to observe that the used swap-space starts to grow right after the box returns. See munin graphs below, the gap (obviously) shows the timeframe in STR.

Memory usage by day

Swap in/out by day

Needless to say that the box becomes unusable while swapping, load goes up beyond 10.

What I've done so far:

  • lowered swappiness from default (60) to 10 (via /etc/sysctl.conf: vm.swappiness=10) -- this has improved the situation much, but sometimes the problem comes back, I have not found a trigger (like memory usage) for this for now
  • lowered swappiness to 5 -- perhaps this has brought an improvement again

Before going to STR the box ran stable without (swapping) problems for hours. Today when the issue showed up again I used this script (-> http://stackoverflow.com/questions/479953/how-to-find-out-which-processes-are-swapping-in-linux) to find what processes have the most used swap space. The result after the swap orgy is like that (all PIDs with more than 10M usage):

Overall swap used: 2121344 kB
========================================
kB  pid name
========================================
439520  17491   java
208148  22719   firefox
136640  4337    /usr/bin/quodli
120852  5271    chrome
81832   5264    chrome
74284   17003   chrome
65368   16960   chrome
57088   3675    chrome
56184   30923   chrome
54412   11331   chrome
54264   3878    chrome
51508   18382   chrome
50088   3163    zeitgeist-fts
49772   15543   chrome
41344   15355   compiz
35040   1161    mysqld
32124   18374   chrome
30940   11339   chrome
30044   5752    chrome
28780   4235    plugin-containe
24576   31246   empathy-chat
23840   17703   chrome
22512   3207    ubuntuone-syncd
21588   1937    ntop
18336   2021    asterisk
17200   3915    chrome
13964   1935    Xorg
12036   10679   chrome
11104   30782   empathy
11056   2889    python
10932   16565   knotify4

The java instance at the top is IntelliJ. IntelliJ, Firefox and Chrome also were all used right before the box was put to STR.

So my question is: can I somehow prevent these swapouts AND why do they happen? Is it perhaps related to some misidentification of idle processes?

I'm not looking for resolutions like:

  • turn off swap
  • buy more RAM

Thanks in advance!

© Ask Ubuntu or respective owner

Related posts about 12.04

Related posts about swap