There should be a simple answer to this, but I wanted to provide context behind it before asking. I suppose this is both a question and a cautionary tale.

What I'd LOVE to be able to do is share a large data structure (a hash of hashes, arrays, and scalars) reliably in a mod_perl environment without incurring the penalty of serializing the data, as is done with IPC::Shareable or IPC::ShareLite via Storable. This doesn't appear to be possible.

The reason I'd love to do this is because serializing with Storable is more expensive than I thought, and is the major performance bottleneck in my application. Luckily, I'm at a point where I can do a redesign without too much pain.

One way I approached it, originally, was to create a global hash %data with use vars qw/%data/;. I have my data structure stored on disk with Storable- what I'd do is compare the modification time of the file on disk with a modification time in the global %data, and if they differed I'd reload the data structure from disk. This didn't work, my guess is because, given that I'm storing the whole data structure as references, and that you can't really depend on globals in a mod_perl environment, that basically NOTHING was as it seems, including the time stamps I was attempting to use for a "staleness" check.

So- stated again- is there any way to RELIABLY share data between mod_perl httpd children without serializing it? My mind says no, but my heart say "god, I hope so.". Perhaps this is a lesson learned- serializing is great, but not for large data structures when performance is concerned.

-Any sufficiently advanced technology is
indistinguishable from doubletalk.


In reply to Sharing data structures in mod_perl by Hero Zzyzzx

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.