Re: swapping of mod_perl parent process / mlockall()

2001-08-01 Thread Doug MacEachern

On Mon, 16 Jul 2001, Adi Fairbank wrote:
 
 Actually, I don't want child processes to inherit the page locks across a
 fork.  I just wanted to experiment with performance issues when only the
 parent process is locked in memory.  (I have a theory that when the parent
 process swaps to disk, the swapped pages become unshared for the rest of the
 server's life)
 
 I was hoping you could give me a hint as to where in the source code I could
 call mlockall(), e.g. file mod_perl.c, line NNN..

you should just be able to create a module with a .xs something like:
#include EXTERN.h
#include perl.h
#include XSUB.h
#include sys/mman.h

MODULE = Mlock  PACKAGE = Mlock 

int
mlockall()

  CODE:
  RETVAL = (mlockall(MCL_CURRENT) == 0);

  OUTPUT:
  RETVAL

and call Mlock::mlockall(); in a startup script.






Re: swapping of mod_perl parent process / mlockall()

2001-07-16 Thread Adi Fairbank

Doug MacEachern wrote:
 
 On Tue, 26 Jun 2001, Adi Fairbank wrote:
 
 
  If this is the case, it would be helpful to prevent the parent process from
  *ever* swapping to disk.
 
  The Linux kernel has a system call mlockall() which disables all memory
  paging for the current process.  This sounds like exactly the recipe for
  preventing parent process swapping.  It won't affect spawned child
  processes, so shouldn't pose a threat of consuming all physical memory and
  crashing the system.
 
  I want to play around with this, but I'm not sure where in the mod_perl
  source to call mlockall().  It would need to be before the parent spawns any
  children..  Has anyone tried using Linux's mlockall()/mlock() with mod_perl?
 
 according the manpage:
 Child processes do not inherit page locks across a fork.
 
 so you would need to call it in a child init handler, but:
 Only root processes are allowed to lock pages.

Actually, I don't want child processes to inherit the page locks across a
fork.  I just wanted to experiment with performance issues when only the
parent process is locked in memory.  (I have a theory that when the parent
process swaps to disk, the swapped pages become unshared for the rest of the
server's life)

I was hoping you could give me a hint as to where in the source code I could
call mlockall(), e.g. file mod_perl.c, line NNN..

Thanks,
-Adi




Re: swapping of mod_perl parent process / mlockall()

2001-07-10 Thread Doug MacEachern

On Tue, 26 Jun 2001, Adi Fairbank wrote:

 
 Is it correct that when the Apache/mod_perl parent process swaps to disk, a
 large part of it (swapped pages) becomes unshared?  Even after the kernel
 restores the pages from swap, do they remain unshared?  So once the parent
 process becomes unshared, new apache children that are spawned only share
 the parent's pages that have never been swapped?
 
 This is what I've grok'ed from my experiments with top/GTop.
 
 If this is the case, it would be helpful to prevent the parent process from
 *ever* swapping to disk.
 
 The Linux kernel has a system call mlockall() which disables all memory
 paging for the current process.  This sounds like exactly the recipe for
 preventing parent process swapping.  It won't affect spawned child
 processes, so shouldn't pose a threat of consuming all physical memory and
 crashing the system.
 
 I want to play around with this, but I'm not sure where in the mod_perl
 source to call mlockall().  It would need to be before the parent spawns any
 children..  Has anyone tried using Linux's mlockall()/mlock() with mod_perl?

according the manpage:
Child processes do not inherit page locks across a fork.

so you would need to call it in a child init handler, but:
Only root processes are allowed to lock pages.