You are not logged in.

#1 2012-11-14 04:22:38

rnarch
Member
Registered: 2012-03-17
Posts: 292

Is swappiness parameter working properly here?

I have added following code to the file /etc/sysctl.conf as suggested by the wiki (https://wiki.archlinux.org/index.php/Ma … erformance):

vm.swappiness=20
vm.vfs_cache_pressure=50

However, I find that swap starts to be used much earlier, e.g. in following output of the command 'free -m'

$ free -m 
             total       used       free     shared    buffers     cached
Mem:           491        485          6          0         25        274
-/+ buffers/cache:        185        305
Swap:         1325        130       1195
$ 

Apparently 305mb are free in buffers/cache but swap has started to be used and the system gets slowed down. Can the use of swap be further reduced?

Offline

#2 2012-11-14 04:50:44

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,412

Re: Is swappiness parameter working properly here?

You don't have very much RAM, so I would expect that the system is being forced to fall back to the swap.  Even if you set it as low as possible, if you don't have enough RAM, that is what swap is there for.  I wouldn't worry about it too much.  Though I may look in to getting more RAM.

Offline

#3 2012-11-14 07:02:33

rnarch
Member
Registered: 2012-03-17
Posts: 292

Re: Is swappiness parameter working properly here?

I want swap to be used when RAM is nearly full. Here RAM seems to be about 63% free (305/485mb) and still the swap has started to be used. Is there any way to avoid this?

Offline

#4 2012-11-14 07:06:34

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,412

Re: Is swappiness parameter working properly here?

You have to consider though that the RAM usage is in constant flux.  So if you were computing to a level at which the ram was nearing full, it would start to page out to swap.  The system then has no means of clearing these paes from the swap (I think it eventually overwrites), so the swap is now in use, and even though your RAM usage went back down, those swap files are still there.

Edit:

rnarch wrote:

... Is there any way to avoid this?

As I said before, get more RAM...

Last edited by WonderWoofy (2012-11-14 07:07:53)

Offline

#5 2012-11-14 12:23:16

kokoko3k
Member
Registered: 2008-11-14
Posts: 1,523

Re: Is swappiness parameter working properly here?

vm.vfs_cache_pressure=100 will help you to swap less.
Don't expect your system to be more responsive, because using less swap when you have not so much ram means using less cache.
If you can't upgrade ram, then i suggest you to try zram https://wiki.archlinux.org/index.php/Ma … e_.2F_Zram and leaving swappines and vm.vfs_cache_pressure to their default values.

Last edited by kokoko3k (2012-11-14 12:24:30)

Offline

#6 2012-11-14 17:09:56

rnarch
Member
Registered: 2012-03-17
Posts: 292

Re: Is swappiness parameter working properly here?

I have made "vm.swappiness=1" as suggested by the article :
http://rudd-o.com/en/linux-and-free-sof … o-fix-that
for which link was given in archwiki :
https://wiki.archlinux.org/index.php/Ma … Swappiness
And it seems to be working. The swap is clearly not being used during my usual computer usage now.

vm.vfs_cache_pressure=100 will help you to swap less.

However, both the above articles are suggesting value of 50 to swap less. I will try this also and see.

Last edited by rnarch (2012-11-14 17:12:36)

Offline

#7 2012-11-15 12:19:29

kokoko3k
Member
Registered: 2008-11-14
Posts: 1,523

Re: Is swappiness parameter working properly here?

The swap is clearly not being used during my usual computer usage now.

And do you feel it more responsive too?

both the above articles are suggesting value of 50 to swap less. 

They don't suggest the value of 50 to swap less, they suggest 50 if you set swappiness to a low value, it's different.

Offline

#8 2012-11-16 06:21:01

rnarch
Member
Registered: 2012-03-17
Posts: 292

Re: Is swappiness parameter working properly here?

I tried values of 100 as well as 10 for vm.vfs_cache_pressure (with vm.swappiness=0 or 1). However, I find that swap starts being used when about 65% of memory is used. Can I make some change so that swap usage is started only when 90% of memory is used up?

Also, once swap is used, it is not freed even if I reduce RAM usage by closing down the applications. As a result, system continues to stay slow unless rebooted.

Last edited by rnarch (2012-11-16 06:23:07)

Offline

#9 2012-11-16 06:26:49

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,412

Re: Is swappiness parameter working properly here?

rnarch wrote:

Also, once swap is used, it is not freed even I reduce RAM usage by closing down the applications.

Didn't I already mention this earlier in the thread.  Specifically:

WonderWoofy wrote:

The system then has no means of clearing these paes from the swap (I think it eventually overwrites), so the swap is now in use, and even though your RAM usage went back down, those swap files are still there.

I did miss the 'g' in pages though, so I can totally see how that would invalidate the rest of the sentence.

Ultimately, I think the system knows best what it is doing, so you are trying to override what the system thinks it should be doing in order to maintain a usable system.  No offense, but this seems rather foolish.

Offline

#10 2012-11-16 07:20:56

rnarch
Member
Registered: 2012-03-17
Posts: 292

Re: Is swappiness parameter working properly here?

I know the easier option is to increase the RAM, which I most likely will, as you suggest. But my main question was:

Can I make some change so that swap usage is started only when 90% of memory is used up?

Offline

#11 2012-11-16 07:54:50

ijanos
Member
From: Budapest, Hungary
Registered: 2008-03-30
Posts: 440

Re: Is swappiness parameter working properly here?

rnarch wrote:

I know the easier option is to increase the RAM, which I most likely will, as you suggest. But my main question was:

Can I make some change so that swap usage is started only when 90% of memory is used up?

You are not reading free output properly. You have 6megabytes free which is little more than 1% of your ram, 98,8% is full.

You think you have that 305 megabytes free because it is "just" for cache, but you don't really want to use a computer that doesn't cache data.

The Linux kernel can figure out when to swap, don't tinker with swappines too much. If it is running smooth then just don't worry about it.

Offline

#12 2012-11-16 08:05:50

rnarch
Member
Registered: 2012-03-17
Posts: 292

Re: Is swappiness parameter working properly here?

Thanks for the explanation.

Offline

Board footer

Powered by FluxBB