Re: Over used cache memory?

From: Daniel Gryniewicz
Date: Thu Nov 06 2003 - 15:51:28 EST

On Thu, 2003-11-06 at 14:57, Maciej Zenczykowski wrote:
> > On Thursday, 06 November 2003, at 17:15:33 +0800,
> > Wee Teck Neo wrote:
> >
> > > 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
> > >
> > > 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.

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.
Daniel Gryniewicz <dang@xxxxxxxxxxx>

Attachment: signature.asc
Description: This is a digitally signed message part