Over used cache memory?
procs memory swap io system
cpu
r b w swpd free buff cache si so bi bo in cs us sy id 1 0 0 92744 9640 20240 801644 0 0 3 10 17 0 25 2 10
This one will be wierd.
I'm having 4 program running at background using 50MB each (got it from "top") Total up to about 200MB.
The system is having 1GB ram and currently using 92MB as swap. Why does the system use the slower swap when there are still memory available (as cache). Anyway to "force" the system to use more ram instead of putting into swap memory?
----Original Message Follows----
From: Helge Hafting <[email protected]>
To: Wee Teck Neo <[email protected]>
CC: [email protected]
Subject: Re: Over used cache memory?
Date: Thu, 06 Nov 2003 10:11:50 +0100
Quoted 9 lines · Wee Teck Neo
My system having 1GB ram and this is the output of vmstat
procs memory swap io system
cpur b w swpd free buff cache si so bi bo in cs us sy id 0 0 0 5640 21224 121512 797832 0 0 6 9 3 17 0 0 6It seems that 797MB is used for caching... thats a high number. Anyway to set a lower cache size?
Yes - _use_ the memory for something else. 1. All unused memory will be put to good use as cache.
2. Memory is taken from the cache whenever you need it for
something else, so (1) is not a problem at all.
Helge Hafting
_________________________________________________________________
Take a break! Find destinations on MSN Travel. http://www.msn.com.sg/travel/
Quoted 10 lines · Wee Teck Neo
procs memory swap io system
cpur b w swpd free buff cache si so bi bo in cs us sy id 1 0 0 92744 9640 20240 801644 0 0 3 10 17 0 25 2 10The system is having 1GB ram and currently using 92MB as swap. Why does the system use the slower swap when there are still memory available (as cache). Anyway to "force" the system to use more ram instead of putting into swap memory?
The obvious solution is to disable swap memory completely if those 90 MiB worth of idle and unused memory pages on disk bother you.
If this "vmstat" output shows your box usual load, with 80% of RAM used in caches, I think you will never really need swap at all.
Signature · 2 lines
Jose Luis Domingo Lopez Linux Registered User #189436 Debian Linux Sid (Linux 2.6.0-test9-mm1)
Quoted 8 lines
Quoted 5 lines · Wee Teck Neo
procs memory swap io system
cpur b w swpd free buff cache si so bi bo in cs us sy id 1 0 0 92744 9640 20240 801644 0 0 3 10 17 0 25 2 10
Quoted 4 lines
Quoted 4 lines
The system is having 1GB ram and currently using 92MB as swap. Why does the system use the slower swap when there are still memory available (as cache). Anyway to "force" the system to use more ram instead of putting into swap memory?
Why would you want to? The kernel has determined that 92MB of the stuff in memory is less important than the disk cache. For example a program requires 100 MB data for boot and then spends the next week using the last 5 MB. Do you expect all 100 MB to stay resident in memory for ever (while the program is running)? Of course not, it'll get swapped out once it is determined to be less used than the disk cache and only that last 5 MB which is actually doing something will remain in RAM, with the rest quietly sitting in swap. Swap is slower than RAM, sure, but using RAM for storing your dirty laundry from two weeks ago is pointless - and that's why it's swapped out - the disk cache will likely accelerate stuff more than keeping the odds and ends in memory.
Now, if you have lots of cache and the system is swapping like crazy - then something is wrong, but only then.
Quoted 5 lines
The obvious solution is to disable swap memory completely if those 90 MiB worth of idle and unused memory pages on disk bother you.
If this "vmstat" output shows your box usual load, with 80% of RAM used in caches, I think you will never really need swap at all.
I wouldn't agree with that - It'll still swap via R/O text executable pages, so you'll still have swap, just invisible.
Cheers,
MaZe.
Quoted 13 lines · Maciej Zenczykowski
Quoted 8 lines
Quoted 5 lines · Wee Teck Neo
procs memory swap io system
cpur b w swpd free buff cache si so bi bo in cs us sy id 1 0 0 92744 9640 20240 801644 0 0 3 10 17 0 25 2 10Quoted 4 lines
Quoted 4 lines
The system is having 1GB ram and currently using 92MB as swap. Why does the system use the slower swap when there are still memory available (as cache). Anyway to "force" the system to use more ram instead of putting into swap memory?
Quoted 11 lines
Why would you want to? The kernel has determined that 92MB of the stuff in memory is less important than the disk cache. For example a program requires 100 MB data for boot and then spends the next week using the last 5 MB. Do you expect all 100 MB to stay resident in memory for ever (while the program is running)? Of course not, it'll get swapped out once it is determined to be less used than the disk cache and only that last 5 MB which is actually doing something will remain in RAM, with the rest quietly sitting in swap. Swap is slower than RAM, sure, but using RAM for storing your dirty laundry from two weeks ago is pointless - and that's why it's swapped out - the disk cache will likely accelerate stuff more than keeping the odds and ends in memory.
Because your mozilla and evolution got swapped out overnight in favor of cache touched by updatedb? Then, when you get in in the morning, your mozilla and evolution take forever to swap in, which is very annoying. Frankly, I don't care at all if the updatedb takes slightly longer due to less cache space, as long as my evolution and mozilla are not swapped out. This is why I don't have any swap on my desktop. Responsiveness of the desktop is much more important to me than any speed-up of cron-based cache-limited processes.
A possibly better solution to this, in my opinion, would be a way to mark a working set, which get's swapped in as soon as there's space (ie as soon as cache get's older than some amount of time). This would allow mozilla to be swapped out in favor of cache during the night, and then swapped back in automatically when that cache ages out. Obviously this would need to be disabled on multiuser systems, but would help, I believe, on desktops. Then again, I have no time or skill to code it, so feel free to ignore me completely. :) The "no swap" solution works great for me.
Signature · 1 line
Daniel Gryniewicz <[email protected]>