Narins, Josh wrote: > Call me an idiot. > > How is it even remotely possible that turning off swap restores memory > shared between processes? Is the Linux kernel going from process to process > comparing pages of memory as they re-enter RAM? "Oh, those two look > identical, they'll get shared?"
You actually can do this. See the mergemem project: http://www.complang.tuwien.ac.at/ulrich/mergemem/ I've never tried it myself, so if anybody did please share your experience. > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Thursday, March 14, 2002 8:24 AM > To: Bill Marrs > Cc: [EMAIL PROTECTED] > Subject: Re: loss of shared memory in parent httpd > > > >>>>>>On Thu, 14 Mar 2002 07:25:27 -0500, Bill Marrs <[EMAIL PROTECTED]> >>>>>> > said: > > >> It's copy-on-write. The swap is a write-to-disk. > >> There's no such thing as sharing memory between one process on > disk(/swap) > >> and another in memory. > > > agreed. What's interesting is that if I turn swap off and back on > > again, the sharing is restored! So, now I'm tempted to run a crontab > > every 30 minutes that turns the swap off and on again, just to keep > > the httpds shared. No Apache restart required! > > Funny, I'm doing this for ages and I never really knew why, you just > found the reason, Thank You! My concerns were similar to yours but on > a smaller scale, so I did not worry that much, but I'm running a > swapflusher regularly. > > Make sure you have a recent kernel, because all old kernels up to > 2.4.12 or so were extremely unresponsive during swapoff. With current > kernels, this is much, much faster and nothing to worry about. > > Let me show you the script I use for the job. No rocket science, but > it's easy to do it wrong. Be careful to maintain equality of priority > among disks: > > use strict; > > $|=1; > print "Running swapon -a, just in case...\n"; > system "swapon -a"; > print "Running swapon -s\n"; > open S, "swapon -s |"; > my(%prio); > PARTITION: while (<S>) { > print; > next if /^Filename/; > chop; > my($f,$t,$s,$used,$p) = split; > my $disk = $f; > $disk =~ s/\d+$//; > $prio{$disk} ||= 5; > $prio{$disk}--; > if ($used == 0) { > print "Unused, skipping\n"; > next PARTITION; > } > print "Turning off\n"; > system "swapoff $f"; > print "Turning on with priority $prio{$disk}\n"; > system "swapon -p $prio{$disk} $f"; > } > system "swapon -s"; > > > Let me know if you see room for improvements, > > Regards, > -- _____________________________________________________________________ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://ticketmaster.com http://apacheweek.com http://singlesheaven.com http://perl.apache.org http://perlmonth.com/