Vivek Khera wrote:
I think that the docs for freebsd should note that the shared size
computation is totally incorrect -- as it is now it only gives you the
shared text segment, which is essentially only the compiled C code
parts of perl.

Yes. Here's a complete answer on the subject from Doug Steinwand, who wrote the FreeBSD support:


Unfortunately, FreeBSD does not track shared memory like Linux does.
The getrusage() system call is rather old-school, and the values
returned from it do not account for copy-on-write memory that occurs
after a fork(). In other words, the size of the process's text pages
(ru_ixrss) is the only useful measurement of shared memory that I
know of.

So, ru_idrss and ru_isrss return the "unshared" memory used by the
data and stack segments respectively, but ru_idrss does not subtract
for copy-on-write, so there's not much point in returning it in
Apache::SizeLimit.

Furthermore, the values returned by these integral elements (ru_ixrss,
ru_idrss, ru_isrss) must be divided by the number of ticks that the
process has been executing. This can be done with the code below,
but it's too not pretty.

use BSD::Resource;
use POSIX;

# returns (total size, shared) via getrusage()
# Note that shared is just the size of text pages. BSD
# doesn't calculate the size of pages shared between data pages
# in different processes.
sub bsd_size_check {
  my @u = BSD::Resource::getrusage( BSD::Resource::RUSAGE_SELF );
  my $clock_ticks = POSIX::sysconf( POSIX::_SC_CLK_TCK );

  # total clock ticks that we've been executing
  my $t = $u[0] * $clock_ticks;

  # too small to calculate, just return maxrss
  if ($t < 0.0001) {
    return ($u[2], 0);
  }

  my $xrss = $u[3] / $t;         # shared memory (text) size
  my $drss = $u[4] / $t;         # unshared data size
  my $srss = $u[5] / $t;         # unshared stack size

  return ($xrss + $drss + $srss, $xrss);
}

__END__

So, I don't think FreeBSD will return what the mod_perl folks are
looking for here. The other BSD's are likely the same, but I'm not
100% sure. Sorry.

- Perrin





--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to