The stupid question is the question not asked | |
PerlMonks |
Re^2: IPC:Shareable: Not an array referenceby marioroy (Prior) |
on Oct 11, 2016 at 12:15 UTC ( [id://1173718]=note: print w/replies, xml ) | Need Help?? |
The following is a comparison demonstrating 2 workers incrementing a shared counter variable. The OO interface for MCE::Shared allows for zero-locking at the application level. All 3 snippets involve set and get while incrementing the variable. 1) ipc_shareable.pl
2) mce_shared.pl
3) mce_shared_oo.pl
Results
Fetches require more time on Linux than BSD-based OS in regards to sockets. This is seen not only with Perl/MCE::Shared but also with other languages. I'm not sure why. MCE::Shared is fully wantarray-aware and performs fetches only when requested. Sadly, that is not the case via the TIE interface. Perhaps, this is an unnecessary overhead IMHO in regards to the TIE implementation inside Perl. The following results were obtained by omitting fetches: e.g. $cntr++, $cntr->incr. Fortunately, stores perform similarly between BSD and Linux via the OO interface.
The above is only a glimpse of what is possible with MCE::Shared. The use of parallel data-channels (enabled automatically) for MCE, MCE::Hobo, and threads further reduce latency for the shared-manager process. Calling MCE::Shared->init(), inside the worker, enables the optimization for fork and other parallel modules. This has been an interesting exercise. Thank you Bloehdian for the initial post. Tests were conducted on a Macbook Pro laptop (Haswell architecture) OS X 10.11.6 running at 2.6 GHz 1600 MHz RAM. FreeBSD and Linux are virtual machines managed by Parallels Desktop 11.2.1. Regards, Mario.
In Section
Seekers of Perl Wisdom
|
|