diff options
author | KJ Tsanaktsidis <ktsanaktsidis@zendesk.com> | 2021-11-25 17:56:19 +1100 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-11-26 18:17:54 +0000 |
commit | 18ee38af90b527f617af7bf9bbcf2e8e7cb0df17 (patch) | |
tree | b1c92e9bd1913a330a63edfbcd5b36a4b12b0c7f /.olddoc.yml | |
parent | 00fb3c8fc14c7f02cee27dba076501b30e739445 (diff) | |
download | raindrops-18ee38af90b527f617af7bf9bbcf2e8e7cb0df17.tar.gz |
Currently, all memory used by Raindrops is mapped as MAP_ANONYMOUS. This means that although Raindrops counters can be shared between processes that have forked from each other, it is not possible to share the counter values with another, unrelated process. This patch adds support for backing the Raindrops mapping with a file descriptor obtained from an IO object. The #initialize API has been enhanced with two new keyword options: Raindrops.new(size, io: nil, zero: false) If an instance of IO is provided, then the underlying file descriptor for that IO will be used to back the memory mapping Raindrops creates. An unrelated process can then open the same file, and read the counters; either by mmap'ing the file itself (or using Raindrops to do so), or by making ordinary seek()/read() calls if performance is not a concern. Note that the provided IO object _must_ implement #truncate; this is used to set the size of the file to be right-sized for the memory mapping that is created. If the zero argument is passed as true, then the mapping will be zero'd by Raindrops as part of its initialization. If it's false, then the Raindrops counters existing in the file will be preserved. This allows counter values to be persisted (although note that Raindrops makes no attempt to msync the values, so they are not durable to e.g. system crashes). Counter values can easily be shared between processes in-memory only without touching the disk by passing in a File on a tmpfs as the io object.
Diffstat (limited to '.olddoc.yml')
0 files changed, 0 insertions, 0 deletions