in reply to SysV shared memory (Look-Alike) -- pure perl
There's hardly any reason to use SysV shared memory these days. Not for performance, anyway. Plain mmap of a regular file, or anonymous mapping (parent/child scenario) will accomplish much the same. The SysV interface could be convenient in some cases; one example is/was postgres:
PostgreSQL uses System V shared memory, because it provides a feature that is available via neither of the other two systems: the ability to atomically determine the number of processes attached to the shared memory segment.
In your code, the shmwrite() usage is not particularity efficient. (On Linux) each of those writes translate to three system calls — shmctl/shmat/shmdt — and a full memcpy/memset of the segment. IPC::SysV provides shmat, memwrite; the idea of shared memory is to avoid syscalls in the first place.
Finally, to benchmark message passing, one needs both a reader and a writer...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: SysV shared memory (Look-Alike) -- pure perl
by flexvault (Monsignor) on Jul 23, 2014 at 15:28 UTC |