snmalloc icon indicating copy to clipboard operation
snmalloc copied to clipboard

Add alignment to the surface API

Open mjp41 opened this issue 5 years ago • 1 comments

Based on the work in #109 alignment with snmalloc can be implemented extremely efficiently: just two additional instructions, which can be optimised away if the alignment is known to be 1 at compile time.

We should expand the internal alloc functions to take an optional alignment parameter (defaulting to 1). This will be useful for scenarios in Project Verona, and will improve the Rust support in #109.

Integrating it into the internal alloc routines will allow for more efficient detecting corner cases such as zero size or zero alignment by pushing them onto the slow path. This will allow clients to not require checking if it can't be guaranteed by construction.

Currently the maximum alignment we support is SUPERSLAB_SIZE. This is sufficient for most applications, but allowing more would reduce unexpected behaviour. This requires fiddling with the large allocator.

Work items:

  • [ ] Expose alignment at the API level.
  • [x] Enforce power of two alignment on large allocations.

mjp41 avatar Jan 22 '20 12:01 mjp41

I have a PR ready for

Enforce power of two alignment on large allocations

It is just waiting for the refactors in #120 to land on master.

mjp41 avatar Feb 03 '20 18:02 mjp41