Re: thread-safe mmap module ?
by kennethk (Abbot) on Feb 21, 2009 at 21:58 UTC
|
Never used them myself, but a CPAN search for shared cache brings up a number of promising looking modules, including IPC::SharedCache and Cache::FastMmap. The documentation from Cache::FastMmap says: It uses fcntl locking to ensure multiple processes can safely access the cache at the same time. so it should certainly be thread-safe. | [reply] |
|
I don't recommend using IPC::SharedCache. It's slow, and the author himself (samtregar) suggest using something else these days, as you can see in the reviews.
| [reply] |
|
| [reply] |
|
Another result that came up on that page is Cache::FastMmap::WithWin32, which "is a fork of Cache::FastMmap by Rob Mueller to include the Win32 port by Ash Berlin". Once again, never used them, but maybe this would fit your bill?
| [reply] |
|
|
|
|
| [reply] |
Re: thread-safe mmap module ?
by perrin (Chancellor) on Feb 22, 2009 at 00:56 UTC
|
Why don't you use a standard hash shared between the threads? Do you need it to be persistent when you shut down apache? | [reply] |
|
Indeed persistency isn't necessary, although supported; you have a point. I see in CPAN the very promising threads-shared module - its .xs clearly proves the win32 support, and in addition it works in non-threaded environments - great suggestion - thank you -;
| [reply] |
|
You're welcome. There are some other tricks for getting good thread performance with mod_perl, mostly to do with when you load things. If you need more help and suggestions, come visit us on the mod_perl list.
| [reply] |
|
| [reply] |
|
threads:::shared offers a lock() method that is released outside of the {} scope where it is. To try -;
| [reply] |
|
Re: thread-safe mmap module ?
by renodino (Curate) on Feb 22, 2009 at 17:30 UTC
|
Based on other comments, you may not really need process-shared memory, but if you still do, you might check IPC::Mmap. It was developed in part to assist in creating a threads-friendly Perl debugger, so it should be thread safe.
(Hmm, looks like the docs have gotten lost in CPAN's new restriction on package content, you'll have to scroll back to older versions to read the docs)
Perl Contrarian & SQL fanboy
| [reply] |