Shared memory for data structures

Y

Yash

In our Active Perl 5.8 script on Windows 2000, we cache a number of
database tables in memory in hashes, and use them for lookups to be
performed on records being read from a number of files. To make use of
a multiprocessor environment, we spawn multiple processes using fork.
This causes multiple copies of the cache being maintained. We have to
update the cache during the processing in certain cases and hence
would like to keep a single copy so that all processes see the same
lookup data.
Is there a way to let Perl keep some of the hash tables in shared
memory? Can somebody provide relevant pointers/suggestions?

Thanks
Yash
 
P

Peter

Yash said:
In our Active Perl 5.8 script on Windows 2000, we cache a number of
database tables in memory in hashes, and use them for lookups to be
performed on records being read from a number of files. To make use of
a multiprocessor environment, we spawn multiple processes using fork.
This causes multiple copies of the cache being maintained. We have to
update the cache during the processing in certain cases and hence
would like to keep a single copy so that all processes see the same
lookup data.
Is there a way to let Perl keep some of the hash tables in shared
memory? Can somebody provide relevant pointers/suggestions?

Thanks
Yash

I have the same problem and I looked around.
Ther is a shared memory modul in cpan called "Net-Shared". As far as I
eveluated it, it can share scalars only.
I solved my problem using pipes and recreate the senders-hases on the
receivers side.
Another possibility is to share a text file using open.

If you ever get a good solution, let me know!

Peter
 
G

Gregory Toomey

Yash said:
In our Active Perl 5.8 script on Windows 2000, we cache a number of
database tables in memory in hashes, and use them for lookups to be
performed on records being read from a number of files. To make use of
a multiprocessor environment, we spawn multiple processes using fork.
This causes multiple copies of the cache being maintained. We have to
update the cache during the processing in certain cases and hence
would like to keep a single copy so that all processes see the same
lookup data.
Is there a way to let Perl keep some of the hash tables in shared
memory? Can somebody provide relevant pointers/suggestions?

Thanks
Yash

If you want shared data you can use System 5 shared memory, which is
available on just about all unixes/linux. Not sure if there is a Perl
module that supports it though.

gtoomey
 
W

Walter Roberson

:> In our Active Perl 5.8 script on Windows 2000, we cache a number of
:> database tables in memory in hashes,

:If you want shared data you can use System 5 shared memory, which is
:available on just about all unixes/linux.

Gregory, is the OP's Windows 2000 system unix or linux, or even
System V compatible?


To be fair, though, as of Windows 2000 (not earlier), Windows impliments
the POSIX shared memory primitives.

http://www.microsoft.com/technet/itsolutions/interop/sfu/sfuposix.mspx#XSLTsection152121120120
 
M

Mark Clements

Gregory Toomey wrote:

If you want shared data you can use System 5 shared memory, which is
available on just about all unixes/linux. Not sure if there is a Perl
module that supports it though.

Cache::SharedMemoryCache

Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top