Managed Memory

Memory managed by the Dragon runtime/services consists of memory pools and allocations within those pools. Pools are managed by Local Services and can be backed by shared memory or a filesystem. Pools can also be entirely private to a process, but that type of memory cannot be used for inter-process communication. Memory pools have many attributes that describe the type, how the memory is managed, and various other tuning options. Memory allocations from that pool then have the properties of the pool.

Memory pools also have the ability to grow based on demand. If they grow and how they grow is all defined by the attributes of the pool. All of the state for a memory pool and allocations within the pool is directly encoded into the memory (as opposed to being tracked in a given process’s memory). This design allows for further enhancements for fault tolerance, relocation of pools and allocations, and potential for concurrency in operations. All operations on the state are guarded by Dragon Locks. Because of this, the API is completely thread safe.

Another attribute for Dragon managed memory is that handles to allocations and pools come through descriptors. These descriptors can be serialized and communicated to another process. The receiving process can immediately used the reconstructed objects. Interactions with remote memory must involve another process that can directly access the memory. In the Dragon context this will often be the Shepherd. Other services and libraries directly interact with managed memory and pools. Channels, for example, requires Dragon managed memory.

Finally, there are many ways to misuse the memory API. Using a pointer after the associated memory has been released back to the pool, for example, is permitted with undefined results. It is on the user to ensure the safety of operating on memory that can be directly addressed and potentially released by other processes.

Architecture

../../_images/managed_memory.svg

Fig. 63 Architecture of the Managed Memory component

MISSING Description of Request Handler and Pools

Allocations from managed memory pools is implemented using a custom buddy allocator, or Heap Manager. This custom allocator partitions a segment of memory and hands out portions of the memory through an “allocation”. Dragon managed memory uses a hierarchy of heap managers to implement allocations. Bitset and hexdump are support utilities for the heap manager.

Cython Adapters

We provide Cython adapters to the Heap Manager and Managed Memory: