in reply to Re: Fast shared data structures
in thread Fast shared data structures

First of all, I did RTFM and found nothing suitable. Ma data is XML. I have started with a standard - XSLT and found it terribly slow. I have found that anything that is DOM-based or string-parsing based is too slow for my needs.

So I have used XML::Grove to represent and built my XML trees in the application. Simple, fast and clean way to do it. As no suitable XML templating system was available for XML::Grove, I have written a very simple but powerfull templating system with embeded perl commands. very fast indeed, because crawling XML::Grove tree is fast operation, no text parsing, no extensive searches, no overkill-DOM interface overhead.
I pre-parse all the templates on apache start-up and keep that in memory. Embeded-perl templates are stored as coderefs, indeed.

At a 10000feet my application looks like:

  +-------------+ XML  +----------------+ HTML/WML/whatever
  | Application |----->| tmpl processor |----->
  +-------------+      +----------------+
                               ^
                               |
                           templates
Note that I represent XML trees as perl hashes, not a strings, so any IPC between application and templating modules will make the whole system ineffective.

But if there is no module to share that data (as you indicated) could anyone provide me with any idea how to share a coderef between two processes? I thought that P-code is the same, no matter in what perl interpreter it runs in. I need this only for processes with the same (or very similar) symbol tables - processes forked from the same parent (typical Apache/mod_perl processes).

Replies are listed 'Best First'.
Re: Re: Re: Fast shared data structures
by perrin (Chancellor) on Nov 09, 2001 at 20:14 UTC
    AxKit has made progress on the speed of XML processing. I think it uses a processor from Gnome now. You can also use Template Toolkit with the XML plugin or XML::Simple.

    There's no way to share a coderef short of actually hacking some XS code, and even then it may not be possible. If it was easy, I assume that Storable would already do it. However, it sounds like you're saying that your data is hashes, not code refs. Those can be serialized. You could do a multi-level cache, with an in-memory version and a shared version serialized on disk. Take a look at MLDBM::Sync for an example, or HTML::Template.