linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Over used cache memory?
@ 2003-11-06  8:05 Wee Teck Neo
  2003-11-06  8:25 ` Nick Piggin
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Wee Teck Neo @ 2003-11-06  8:05 UTC (permalink / raw)
  To: linux-kernel

My system having 1GB ram and this is the output of vmstat

   procs                      memory      swap          io     system      
cpu
r  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  
6


It seems that 797MB is used for caching... thats a high number. Anyway to 
set a lower cache size?

I've read about the /proc/sys/vm/buffermem but my /proc doesn't have it.

Kernel: 2.4.22

_________________________________________________________________
Get 10mb of inbox space with MSN Hotmail Extra Storage 
http://join.msn.com/?pgmarket=en-sg


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Over used cache memory?
  2003-11-06  8:05 Over used cache memory? Wee Teck Neo
@ 2003-11-06  8:25 ` Nick Piggin
  2003-11-06  8:59 ` Jerry Lundström
  2003-11-06  9:11 ` Helge Hafting
  2 siblings, 0 replies; 13+ messages in thread
From: Nick Piggin @ 2003-11-06  8:25 UTC (permalink / raw)
  To: Wee Teck Neo; +Cc: linux-kernel



Wee Teck Neo wrote:

> My system having 1GB ram and this is the output of vmstat
>
>   procs                      memory      swap          io     
> system      cpu
> r  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  6
>
>
> It seems that 797MB is used for caching... thats a high number. Anyway 
> to set a lower cache size?
>
> I've read about the /proc/sys/vm/buffermem but my /proc doesn't have it.
>
> Kernel: 2.4.22


Short answer, no.

If it is actually causing you a problem, test the latest 2.4 prerelease.
If that doesn't help, report the details of the problem.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Over used cache memory?
  2003-11-06  8:05 Over used cache memory? Wee Teck Neo
  2003-11-06  8:25 ` Nick Piggin
@ 2003-11-06  8:59 ` Jerry Lundström
  2003-11-06  9:11 ` Helge Hafting
  2 siblings, 0 replies; 13+ messages in thread
From: Jerry Lundström @ 2003-11-06  8:59 UTC (permalink / raw)
  To: Wee Teck Neo; +Cc: linux-kernel

Wee Teck Neo wrote:
> My system having 1GB ram and this is the output of vmstat
> 
>   procs                      memory      swap          io     
> system      cpu
> r  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  6
> 
> 
> It seems that 797MB is used for caching... thats a high number. Anyway 
> to set a lower cache size?
> 
> I've read about the /proc/sys/vm/buffermem but my /proc doesn't have it.
> 
> Kernel: 2.4.22
> 

I don't see the problem? Linux uses unused memory as cache and unless 
you have processes using more memory then thats free you dont have a 
problem, this is all dynamic and nothing to worry about.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Over used cache memory?
  2003-11-06  8:05 Over used cache memory? Wee Teck Neo
  2003-11-06  8:25 ` Nick Piggin
  2003-11-06  8:59 ` Jerry Lundström
@ 2003-11-06  9:11 ` Helge Hafting
  2003-11-06 13:40   ` jlnance
  2 siblings, 1 reply; 13+ messages in thread
From: Helge Hafting @ 2003-11-06  9:11 UTC (permalink / raw)
  To: Wee Teck Neo; +Cc: linux-kernel

Wee Teck Neo wrote:
> My system having 1GB ram and this is the output of vmstat
> 
>   procs                      memory      swap          io     
> system      cpu
> r  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  6
> 
> 
> It 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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Over used cache memory?
  2003-11-06  9:11 ` Helge Hafting
@ 2003-11-06 13:40   ` jlnance
  2003-11-06 14:14     ` Gianni Tedesco
  0 siblings, 1 reply; 13+ messages in thread
From: jlnance @ 2003-11-06 13:40 UTC (permalink / raw)
  To: linux-kernel

On Thu, Nov 06, 2003 at 10:11:50AM +0100, Helge Hafting wrote:
> 
> 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.

This is the way it is susposed to work, but I am working on a problem
where this does not seem to be happening.  We have a machine with 6G
of ram.  It reads some huge files (~5G) and cache fills up.  Then
it starts to process the data and goes into a swap storm because it
can not get any memory for the process because it all is in the cache.
If you run top, you see kswapd stuck at the top.

If anyone has any ideas about this, I would love to hear them.

Thanks,

Jim

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Over used cache memory?
  2003-11-06 13:40   ` jlnance
@ 2003-11-06 14:14     ` Gianni Tedesco
  2003-11-06 21:47       ` jlnance
  0 siblings, 1 reply; 13+ messages in thread
From: Gianni Tedesco @ 2003-11-06 14:14 UTC (permalink / raw)
  To: jlnance; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 608 bytes --]

On Thu, 2003-11-06 at 14:40, jlnance@unity.ncsu.edu wrote:
> If anyone has any ideas about this, I would love to hear them.

cat /proc/pid/maps of app in question....

most likely it's copying a fsck load of that file in to anonymous
mappings, causing swapping.

If it has a 2GB anonymous mapping and 1GB physical memory, swap will
happen on 1 in 2 pages that that program tries to access, on average.

-- 
// Gianni Tedesco (gianni at scaramanga dot co dot uk)
lynx --source www.scaramanga.co.uk/gianni-at-ecsc.asc | gpg --import
8646BE7D: 6D9F 2287 870E A2C9 8F60 3A3C 91B5 7669 8646 BE7D


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Over used cache memory?
  2003-11-06 14:14     ` Gianni Tedesco
@ 2003-11-06 21:47       ` jlnance
  0 siblings, 0 replies; 13+ messages in thread
From: jlnance @ 2003-11-06 21:47 UTC (permalink / raw)
  To: Gianni Tedesco; +Cc: jlnance, linux-kernel

On Thu, Nov 06, 2003 at 03:14:32PM +0100, Gianni Tedesco wrote:
> On Thu, 2003-11-06 at 14:40, jlnance@unity.ncsu.edu wrote:
> > If anyone has any ideas about this, I would love to hear them.
> 

> most likely it's copying a fsck load of that file in to anonymous
> mappings, causing swapping.

Thanks for the reply.  Unfortunatly thats not it.  I can reproduce this
problem with a little program that appends data to a file and every so
often seeks back to the beginning of the file and scribbles a little there.

Thanks,

Jim

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Over used cache memory?
  2003-11-06 19:57   ` Maciej Zenczykowski
@ 2003-11-06 20:50     ` Daniel Gryniewicz
  0 siblings, 0 replies; 13+ messages in thread
From: Daniel Gryniewicz @ 2003-11-06 20:50 UTC (permalink / raw)
  To: Maciej Zenczykowski; +Cc: Jose Luis Domingo Lopez, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2672 bytes --]

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@fprintf.net>

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Over used cache memory?
  2003-11-06 19:07 ` Jose Luis Domingo Lopez
@ 2003-11-06 19:57   ` Maciej Zenczykowski
  2003-11-06 20:50     ` Daniel Gryniewicz
  0 siblings, 1 reply; 13+ messages in thread
From: Maciej Zenczykowski @ 2003-11-06 19:57 UTC (permalink / raw)
  To: Jose Luis Domingo Lopez; +Cc: linux-kernel

> 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.

Now, if you have lots of cache and the system is swapping like crazy - 
then something is wrong, but only then.

> 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.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Over used cache memory?
  2003-11-06  9:15 Wee Teck Neo
@ 2003-11-06 19:07 ` Jose Luis Domingo Lopez
  2003-11-06 19:57   ` Maciej Zenczykowski
  0 siblings, 1 reply; 13+ messages in thread
From: Jose Luis Domingo Lopez @ 2003-11-06 19:07 UTC (permalink / raw)
  To: linux-kernel

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?
> 
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.

-- 
Jose Luis Domingo Lopez
Linux Registered User #189436     Debian Linux Sid (Linux 2.6.0-test9-mm1)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Over used cache memory?
@ 2003-11-06  9:33 Wee Teck Neo
  0 siblings, 0 replies; 13+ messages in thread
From: Wee Teck Neo @ 2003-11-06  9:33 UTC (permalink / raw)
  To: linux-kernel

Ok...... Thanks got an idea how linux uses memory.

Thanks


----Original Message Follows----
From: Jerry Lundström <jerry.lundstrom@it.su.se>
To: Wee Teck Neo <slashboy84@msn.com>
CC: linux-kernel@vger.kernel.org
Subject: Re: Over used cache memory?
Date: Thu, 06 Nov 2003 10:16:19 +0100

Wee Teck Neo wrote:
>But seems like the swap space is begin used because of "insufficent" free 
>memory. I'm not sure if there is a performance slow down.
>

no no no, this is the way linux works. Memory from programs that are not 
accessed alot are put into the swap so that the not-so-offen-used memory can 
be used by other programs or the cache to speed up everything. When that 
program later access the swaped memory it will load it up and remove some of 
the cache and after a while it will put it back into the swap (dont have any 
numbers on how long till it will but trust linux, it does it very good).

I wouldnt worry at all about those numbers, they are very common in 1gig 
server systems and ive worked with alot of them, even 4gig mem systems use 
the swap, thats what its for...

If you are worried about preformance with memory and such after all 
configure you systems like this:

If you use IDE have the system disk on one IDE channel and a standalone swap 
disk on another IDE channel (not master or slave way but ide0 or ide1). For 
SCSI you can just put the swap on a seperate disk.
Doing this will speed up alot of stuff since linux have 100% access to the 
swap when it needs too, it doesnt have to share the IO to the disk with 
another partition.

Otherwise Id just say, dont worry about it... Linux knows what its doing...

hope it helps...

_________________________________________________________________
Keep track of Singapore & Malaysia stock prices. 
http://www.msn.com.sg/money/


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Over used cache memory?
       [not found] <BAY4-F18tJyMmxsywxZ00005d1a@hotmail.com>
@ 2003-11-06  9:16 ` Jerry Lundström
  0 siblings, 0 replies; 13+ messages in thread
From: Jerry Lundström @ 2003-11-06  9:16 UTC (permalink / raw)
  To: Wee Teck Neo; +Cc: linux-kernel

Wee Teck Neo wrote:
> But seems like the swap space is begin used because of "insufficent" 
> free memory. I'm not sure if there is a performance slow down.
> 

no no no, this is the way linux works. Memory from programs that are not 
accessed alot are put into the swap so that the not-so-offen-used memory 
can be used by other programs or the cache to speed up everything. When 
that program later access the swaped memory it will load it up and 
remove some of the cache and after a while it will put it back into the 
swap (dont have any numbers on how long till it will but trust linux, it 
does it very good).

I wouldnt worry at all about those numbers, they are very common in 1gig 
server systems and ive worked with alot of them, even 4gig mem systems 
use the swap, thats what its for...

If you are worried about preformance with memory and such after all 
configure you systems like this:

If you use IDE have the system disk on one IDE channel and a standalone 
swap disk on another IDE channel (not master or slave way but ide0 or 
ide1). For SCSI you can just put the swap on a seperate disk.
Doing this will speed up alot of stuff since linux have 100% access to 
the swap when it needs too, it doesnt have to share the IO to the disk 
with another partition.

Otherwise Id just say, dont worry about it... Linux knows what its doing...

hope it helps...


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Over used cache memory?
@ 2003-11-06  9:15 Wee Teck Neo
  2003-11-06 19:07 ` Jose Luis Domingo Lopez
  0 siblings, 1 reply; 13+ messages in thread
From: Wee Teck Neo @ 2003-11-06  9:15 UTC (permalink / raw)
  To: linux-kernel

   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 <helgehaf@aitel.hist.no>
To: Wee Teck Neo <slashboy84@msn.com>
CC: linux-kernel@vger.kernel.org
Subject: Re: Over used cache memory?
Date: Thu, 06 Nov 2003 10:11:50 +0100

Wee Teck Neo wrote:
>My system having 1GB ram and this is the output of vmstat
>
>   procs                      memory      swap          io     system      
>cpu
>r  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  
>6
>
>
>It 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/


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2003-11-06 21:47 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-06  8:05 Over used cache memory? Wee Teck Neo
2003-11-06  8:25 ` Nick Piggin
2003-11-06  8:59 ` Jerry Lundström
2003-11-06  9:11 ` Helge Hafting
2003-11-06 13:40   ` jlnance
2003-11-06 14:14     ` Gianni Tedesco
2003-11-06 21:47       ` jlnance
2003-11-06  9:15 Wee Teck Neo
2003-11-06 19:07 ` Jose Luis Domingo Lopez
2003-11-06 19:57   ` Maciej Zenczykowski
2003-11-06 20:50     ` Daniel Gryniewicz
     [not found] <BAY4-F18tJyMmxsywxZ00005d1a@hotmail.com>
2003-11-06  9:16 ` Jerry Lundström
2003-11-06  9:33 Wee Teck Neo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).