You really can't access Perl variables in shared memory directly. Systems like IPC::Shareable and memcached will always require you to send the data through Storable and create a separate copy of any data you work with in your process. There is no way around this -- at some point you have to turn the stream of bytes coming from the storage you use into a perl variable, which means creating a new one in your local process. There are faster storage mechanisms than those, like BerkeleyDB, but they all have to create a local variable when you want to do something with the data.

It is possible to load the data up and then fork the processes. It will be shared and there will be only one copy due to copy-on-write. It's read-only though.

It sounds like less than 500MB of data even if you load it separately in 10 programs. That doesn't cost much these days. I'd think twice before spending more time on this.


In reply to Re: Share hash across processes by perrin
in thread Share hash across processes by bmac888

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.