When deserializing a compact_vector, allocate memory with mmap
(anonymous map) and mark the map as "shared" and "read-only".
Large memory allocations are usually satisfied with mmap. So this
should not change much in practice compared to doing malloc().
For Salmon server, having shared memory blocks should be very
beneficial: shared mappings do not cost any memory when doing a
fork().
This largely fix a problem with the Salmon server where the fork would fail because there is not enough memory. Even with copy-on-write, the system check that there is enough memory available to duplicate the pages in case the child process modify them. By declaring the page "shared", a page is accounted for only once, instead of once per fork.
When deserializing a compact_vector, allocate memory with mmap (anonymous map) and mark the map as "shared" and "read-only".
Large memory allocations are usually satisfied with mmap. So this should not change much in practice compared to doing
malloc()
.For Salmon server, having shared memory blocks should be very beneficial: shared mappings do not cost any memory when doing a
fork()
.This largely fix a problem with the Salmon server where the fork would fail because there is not enough memory. Even with copy-on-write, the system check that there is enough memory available to duplicate the pages in case the child process modify them. By declaring the page "shared", a page is accounted for only once, instead of once per fork.