perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Foertsch <>
Subject Re: Loading at startup to use shared memory
Date Tue, 07 Nov 2006 16:17:54 GMT
On Tuesday 07 November 2006 13:28, Kjetil Kjernsmo wrote:
> > What operating system is it? If linux see
> >
> >
> Yep, it is GNU/Linux, kernel 2.6.17.
> That's very interesting. I hadn't read up on that, because I thought
> Apache2::Resource did the same thing, but yeah, I think that is
> something we want to look into. Also, you're saying that the
> $Apache2::SizeLimit::HOW_BIG_IS_IT is a better way to assess the shared
> memory usage then GTop?

You can directly look at /proc/<PID>/smaps or use Linux::Smaps. I don't know 
what GTop does but I know how /proc/<PID>/smaps work. Also, don't do it too 
often. Reading from /proc/<PID>/smaps is really expensive particularly for 
large process sizes.

Maybe I forgot to say in the docs, /proc/<PID>/smaps cannot determine if a 
page is shared or private if it is out of core (paged out). Hence to make 
your measurement accurate you must lock the parent apache in core or turn off 
swapping completely.

Locking the parent apache in memory can be done this way:

require '';
require 'sys/';

0==syscall &SYS_mlockall, &MCL_CURRENT | &MCL_FUTURE or
  die "ERROR: mlockall failed: $!\n";

or a bit simpler

0==syscall 152, 3 or
  die "ERROR: mlockall failed: $!\n";

This prevents only the parent apache from being paged. The child processes 
wont. But since the parent is always in core all shared pages are so.

@Dave, maybe you could add a word about the mlockall to the linux section of 


View raw message