ltsmin
ltsmin copied to clipboard
Improve multi-process memory management
The current allocator in the multi-process environment (--procs=P) is a hack. It claims a large piece of anonymous pages using mmap at pre-fork time. Memory allocations are handled by giving out pointers continuously from this region (HREdefaultRegion(HREglobal()) is automatically set in the process environment). For lack of administration freeing or reallocating memory is not possible.
To limit fragmentation two sets of functions were designed: RTmalloc(...) - for local (non-scaling) allocation by the OS HREmalloc(region, ...) - allocating from a designate region (Warning: it may fall back on RTmalloc)
RTswitchAlloc (true/false) is used to switch the behavior of RTmalloc to HREmalloc(HREdefaultRegion(HREglobal()), ...) transparently. This enables the use of allocator oblivious data structures.
TODO: 1 - integrate a true allocator that works with inter-process memory. a viable option seems the simple SSmalloc, it needs to be adapted to used the preallocated region though 2 - consolidate HREmalloc and RTmalloc (See #698) with good allocator, HREmalloc with default region can be used as default