You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Anthony Gardner <cy...@yahoo.co.uk> on 2007/01/04 10:48:03 UTC

Caching Filehandles

Happy New Year mod_perl(ers) (just buttering you up b4 I ask my question ;) )

Am working my way through a lot of existing code that was run as vanilla CGI and which we are porting to MP2(ish).

anyway, they have their own html templates which are opened and closed for every request. Doh!!

Before we go over to a REAL templating system, I'm trying to squeeze a bit of extra performance out of their code and I thought of either reading the files into memeory at server start up or caching the filehadles when they're opened for the first itme.

I'm starting with the FH idea first and my approach is to Symbol to genrate unique filehandles, store those in a hash (Tie::RefHash) with a timestamp and then have another cache where the FH is the key and the FH is the value.

My question is .... how many FH's can I have open per Apache process at any one time? Don;t know if this would be limited by Perl or MP.

Also, is there a real benifit of this approache as for each read of the file, I have to reset the FH position and think that might be as slow as an open/close operation.

Would I just be better off not doing this and just whacking everything into memeory to begin with.

CIA

-Ants
 

 Send instant messages to your online friends http://uk.messenger.yahoo.com