microsoft / microsoft/snmalloc
Add alignment to the surface API
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 2k
- Forks
- 138
- Avg merge
- 11h 19m
- Merged PRs (30d)
- 5
Description
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.
- Enforce power of two alignment on large allocations.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the work in #109 and the internal alloc routines, then trace how the surface API reaches the large allocator. Check the existing power-of-two alignment handling and determine the API and slow-path cases that need to be covered. Done means alignment is exposed at the API level while preserving the documented maximum-alignment behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend, performance
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100