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 12:18:23 UTC
Caching Filehandles (seen some light!!)
Just realised, I could use Apache::Cache. Is there an MP2 version? Couldn't find one.
Send instant messages to your online friends http://uk.messenger.yahoo.com
Re: Caching Filehandles (seen some light!!)
Posted by Jonathan Vanasco <mo...@2xlp.com>.
On Jan 4, 2007, at 11:44 AM, Perrin Harkins wrote:
> There's probably not much benefit from caching filehandles if you
> still have to read the files anyway. The best thing to do would be
> to port to a more mature templating system. Short of that, caching
> the templates in memory (just in a hash, not in a shared cache like
> the ones above) will give the biggest performance boost.
Agreed.
Using the filesystem handles as you described would actually be
detrimental -- aside from the fact that you still have to read the
files , you're looking at a lot of read/write on the memory related
to the files -- on a per child basis. If you've got a single class
handling it with a single variable, figure that you're going to
consume memory representing the largest file you'll be reading -- per
child. A lot of caching optimizers I've seen will store data in a
string that is md5(file) -- which means you can have a var per file,
per child -- which is a lot.
I'd strongly suggest to cache the files into memory at server start
so that they're shared by all the children. If you need something
quick, just create a class to manage 'reading' files that stores the
data into a md5( /path/to/file ) variables on startup, and returns a
ref to the string as needed. shouldn't take more than 30minutes to
implement on the trickiest system.
// Jonathan Vanasco
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
| FindMeOn.com - The cure for Multiple Web Personality Disorder
| Web Identity Management and 3D Social Networking
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
| RoadSound.com - Tools For Bands, Stuff For Fans
| Collaborative Online Management And Syndication Tools
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
Re: Caching Filehandles (seen some light!!)
Posted by Perrin Harkins <pe...@elem.com>.
Anthony Gardner wrote:
> Just realised, I could use Apache::Cache.
Don't use that. The shared memory implementation is really slow. If
you need a cache, use Cache::FastMmap.
A cache of this kind is not what you need for this though. You can't
stuff filehandles into it.
There's probably not much benefit from caching filehandles if you still
have to read the files anyway. The best thing to do would be to port to
a more mature templating system. Short of that, caching the templates
in memory (just in a hash, not in a shared cache like the ones above)
will give the biggest performance boost.
- Perrin