Skip to content

Heap/Slab allocators: separate mechanism from API #5515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
nfeske opened this issue Apr 7, 2025 · 0 comments
Open

Heap/Slab allocators: separate mechanism from API #5515

nfeske opened this issue Apr 7, 2025 · 0 comments
Labels

Comments

@nfeske
Copy link
Member

nfeske commented Apr 7, 2025

The Heap and Slab allocators implement the Allocator interface by operating on a Ram_allocator and a local Region_map (the component's virtual memory. Since all these interfaces are fixed, they are not always a perfect fit:

  • The virtual address space of the core component is not a region map. To nevertheless use Heap and Slab within core, a pseudo region-map implementation is needed, which imposes the use of dataspaces onto core, which in turn adds complexity to no benefit.

  • The new operator requires exception support to reflect allocation errors. The Allocator interface is thereby "infected" by the C++ exception mechanism. To move away from C++ exceptions, we need to abolish the use of new (Allocator &). However, without new there is no good reason for the Allocator interface to exist in the first place.

  • Allocator::alloc takes the number of bytes as argument. This makes no sense for the slab. The invariant that the allocation size fits a slab entry cannot be ensured at compile time.

These are good reasons to revise the Heap and Slab to model different allocation scenarios (core/outside core, constrained/unconstrained) via exception-free interfaces. So avoid duplicating the allocator's implementation for each scenario, the mechanism for the allocators (using one specific type each) must be separated by their (templated) API (allowing for different types of heaps and slabs).

@nfeske nfeske added the cleanup label Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant