Just another Perl shrine | |
PerlMonks |
Fast shared data structuresby gildir (Pilgrim) |
on Nov 08, 2001 at 22:09 UTC ( [id://124115]=perlquestion: print w/replies, xml ) | Need Help?? |
gildir has asked for the wisdom of the Perl Monks concerning the following question:
Fellow monks,
I was working on a mod_perl templating system. As a speed is a primary issue, I read and pre-process all template data at server start-up. Pre-processed templates are stored in memory of Apache master server as one huge perl hash, and I let the OS copy-on-write do effecient sharing in subprocesses. All works fine so far. But now I want allow users of my system to change templates when server is running. Kind of 'hot-swap' template feature. I know how to detect changed templates, how to re-parse tham and all such things. The problem is memory. If I do template re-parsing in every apache child process, memory consumption will be $size_of_tempate*$num_of_processes, because copy-on-write sharing will not take place here. Most undesirable situation if the size of parsed templates is 10MB ... Some kind of shared memory hit my mind at this moment and I began a search. I have found IPC::Shareable and it looks ideal at first glance. But alas, it does freeze/thaw cycles all the time and that will affect performance very badly. I want templating system to be very fast, in-memory native perl hashes seems to be best solution. Is there any way how I can share perl hash directly between Apache processes? Most of the time I will be reading that hash. When writing, all operations on the hash may block, that is no problem. Can anyone please turn my nose in the right direction? Or maybe my thoughts go all the wrong way from the very begenning ....
Back to
Seekers of Perl Wisdom
|
|