I briefly asked about this in a previous post, but I wanted to follow up.

I'm curious but not very experienced, so any comments would be welcome...

I have a home-built template cache system that is limited by size.  I was
logging failed cache hits (and thus reloading a template from disk) and was
surprised at how often it was happening. So...

I like the ideas of converting templates to subroutines and then caching
those on disk.  I really like the idea of then bringing those into the
server and compiling them and keeping a cache of those compiled subroutines
in memory.  Having the templates in the cache seems like a big win, so one
would want to keep as many templates in the cache as possible.

This in-memory cache must be limited and controlled to some degree I would
expect, especially since they cannot be shared across mod_perl server
children to save memory.

Now, let say for once we do have a limited amount of memory, and we have a
very large number of templates, and the templates are very large and mostly
plain old text.  In other words, the compiled templates are basically big
print statements with only a small part being variable interpolation.
Since the templates are large, I could imagine a situation where the
compiled template cache is thrashed, or at least the templates don't live
in the cache very long.

As someone who used to program on machines with 8K, all that plain old text
in non-shared memory bugs me a bit.

Maybe this is already being done, but I was wondering if separating the
templates into text and code segments might allow more templates (template
code, that is) to be placed in the running server's cache at any given time
would make any sense.  

It would be slower to generate a page, of course, but that might be offset
by a greater cache hit-rate and less reloading & compiling of templates.
And the text segments could be shared by all server processes by using
IPC::Sharable -- or maybe it would be fast enough to let the OS file system
buffer the commonly used templates, or use a database to load the text
segments.

So my question is only would such a system make sense, or is memory so
inexpensive and templates normally so small that there wouldn't be any
benefit?



Bill Moseley
mailto:[EMAIL PROTECTED]

Reply via email to