On Tuesday 07 November 2006 13:28, Kjetil Kjernsmo wrote: > > What operating system is it? If linux see > > http://search.cpan.org/~drolsky/Apache-SizeLimit-0.9/lib/Apache/SizeL > >imit.pm#linux > > 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: <Perl> require 'syscall.ph'; require 'sys/mmap.ph'; 0==syscall &SYS_mlockall, &MCL_CURRENT | &MCL_FUTURE or die "ERROR: mlockall failed: $!\n"; </Perl> or a bit simpler <Perl> 0==syscall 152, 3 or die "ERROR: mlockall failed: $!\n"; </Perl> 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 Apache::SizeLimit? Torsten
pgpCBYaK6BrBw.pgp
Description: PGP signature