Re: Prefork not sharing on FreeBSD, but sharing on OSX ?
I'll be following this thread with interest as I'm seeing similar behaviour on my FreeBSD box. I also have a local server on OSX. My Apache children are around 20MB of OSX and 75MB on FreeBSD. This is using top to measure. I'm also getting an awful lot of seg faults in the log but I haven't isolated that to perl yet and the server comes with mod_php installed as well. Which I have got to get rid of. My Perl code is 2MB in total (37 packages). I have still got a *lot* to learn about how mod_perl loads things and allocates them into ram but I'll not hijack this thread with that. Any pointers to manuals greatly appreciated. I'm also running prefork. I'll look into finding out how Apache::Status can tell me what's loaded. Hoping to be able to confirm your findings here.
Sort issue
Hi I would like to do some custom sorting with some hash data that I have stored. It will be used in a mod_perl application so I would like to ensure that the variables are safe and local. My worry is that I plan to call a subroutine with sort but I have no idea how to pass the variables or if I even have to. Here is what I am planning. Any advice or links would help. Thanks a lot. Mike @sortedkeys = sort by_field keys(%names); sub by_fields { my ($first_compare,$first_extra) = $names{$a}; my ($second_compare,$second_extra) = $names{$b}; ### I am spliting the value to sort on a secondary field other than the key ($first_compare = $second_compare || $first_extra = $second_extra); }
Re: status() vs constants
On Sat, 2006-08-12 at 16:46 -0400, Michael Peters wrote: Now, in my handler sub I want to return the corresponding constant for whatever status() is set to. Under mod_perl 1.x this worked by just returning the status() since OK == 200, SERVER_ERROR == 500, etc. But this isn't true under mod_perl 2 (as far as I can tell). My module needs to work under both, so I need a better way. The HTTP constants all have names like HTTP_OK rather than OK. They are not guaranteed to match the handler return codes, although many of them do. I'd rather not have to check every possible status() value in a huge if/else tree to return the right constant You could make a hash that maps handler response codes to HTTP codes. Most people don't need to do that because they only use one or two codes. - Perrin
Re: Memory Usage Reporting?
I did some tests, some interesting results my processes no longer seem to be 300mb. which is good. however, when that happened, i was seeing a 300mb process and then 6mb in a child. now i'm back to seemingly unshared memory. based on my tests below, i *think* that it may have been because i was doing apachectl restarts, and not clean stop/starts i've noticed that my parent and works take on an additional 30mb of memory every time an apachectl restart is issued. i thought to myself, ugh - thats what you get for not using a graceful well , graceful does the same thing. i'm more lost now than i was yesterday --- StartServers 1 MinSpareServers1 MaxSpareServers1 MaxClients 2 MaxRequestsPerChild 1 === Trial 1 start @end of startup.pl GTop(2207) 23457792 ps aux root 2210 0.0 5.5 59488 55284 www 2214 0.0 5.5 59548 55340 Note: ps-aux should be larger. a) in almost every other trial it was showing something closer to Gtop b) it is post-init @four requests GTop preview_check Size Before: (2241) 48320512 preview_check Size After: (2241) 48398336 handler Size Pre- Page: (2241) 48410624 handler Size Post- Page: (2241) 48484352 preview_check Size Before: (2214) 48582656 preview_check Size After: (2214) 48582656 handler Size Pre- Page: (2214) 48582656 handler Size Post- Page: (2214) 48582656 Note: preview_check is run on the init, checks cookies and sets up the ctx object/page user. redirects to login screen if request invalid, redirects to preview site if not in alpha test handler is the content generation phase on both the first value is from first line of the handler, the second value is the last line ps aux root 2210 0.0 5.5 59488 55284 ?? Ss3:21PM 0:02.53 / usr/local/sbin/httpd www 2214 0.0 5.5 59900 55608 ?? S 3:21PM 0:00.10 / usr/local/sbin/httpd www 2241 0.0 5.5 59860 55584 ?? S 3:26PM 0:00.08 / usr/local/sbin/httpd Trial 2 apachectl restart @end of startup.pl - console GTOP(2256) 23457792 @end of startup.pl - logs GTOP(2210) 70836224 ps aux root 2210 0.0 7.7 81776 77484 www 2261 0.0 7.7 81832 77556 @ four requests GTOP preview_check Size Before: (2261) 72237056 preview_check Size After: (2261) 72237056 handler Size Pre- Page: (2261) 72237056 handler Size Post- Page: (2261) 72237056 ps aux root 2210 0.0 7.7 81776 77484 www 2261 0.0 7.8 82956 78640 ++ StartServers 2 MinSpareServers 5 MaxSpareServers 10 MaxClients 10 MaxRequestsPerChild 1 === start @end of startup.pl GTop(2307) 23457792 ps aux root 2310 2.4 5.5 59488 55284 www 2314 0.0 5.5 59548 55340 www 2315 0.0 5.5 59548 55340 www 2320 0.0 5.5 59548 55340 www 2323 0.0 5.5 59548 55340 www 2324 0.0 5.5 59548 55340 @ four requests preview_check Size Before: (2320) 48734208 preview_check Size After: (2320) 48734208 handler Size Pre- Page: (2320) 48734208 handler Size Post- Page: (2320) 48734208 restart @ startup.pl - console GTop
Re: status() vs constants
Now, in my handler sub I want to return the corresponding constant for whatever status() is set to. Under mod_perl 1.x this worked by just returning the status() since OK == 200, SERVER_ERROR == 500, OK is not 200. OK is 0, HTTP_OK is 200. 'tis always been this way :) etc. But this isn't true under mod_perl 2 (as far as I can tell). mp1 assumed that if you returned 200 (HTTP_OK) you really meant 0 (OK). this is no longer true with mp1. if you do the right thing (return OK, not HTTP_OK) then both mp1 and mp2 do the right thing. in general, you should never worry about $r-status - whether you're in mp1 or mp2, your handler() subroutine should always return either one of OK, DECLINED, or DONE, or some HTTP _error_ code (like 500, 304, etc). over in httpd land apache will translate your return value into a suitable value of $r-status (which isn't always the same as what you returned, such as when you're in an ErrorDocument it will force $r-status to whatever the original error status was if your ErrorDocument returns 500). HTH --Geoff
Re: Sort issue
After a few off list hints and hours of searching and reading I have solved the issue. Here is the link to the page I found helpful. Very belated thanks (almost 6 years) goes to Stas Bekman. Mike http://www.gossamer-threads.com/lists/modperl/modperl/35645?search_string=so rt%20subroutine;#35645 - Original Message - From: Mike OK [EMAIL PROTECTED] To: modperl@perl.apache.org Sent: August 13, 2006 11:32 AM Subject: Sort issue Hi I would like to do some custom sorting with some hash data that I have stored. It will be used in a mod_perl application so I would like to ensure that the variables are safe and local. My worry is that I plan to call a subroutine with sort but I have no idea how to pass the variables or if I even have to. Here is what I am planning. Any advice or links would help. Thanks a lot. Mike @sortedkeys = sort by_field keys(%names); sub by_fields { my ($first_compare,$first_extra) = $names{$a}; my ($second_compare,$second_extra) = $names{$b}; ### I am spliting the value to sort on a secondary field other than the key ($first_compare = $second_compare || $first_extra = $second_extra); } -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.10.7/411 - Release Date: 2006-08-07