-
Notifications
You must be signed in to change notification settings - Fork 109
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
Make Large allocations naturally aligned #124
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This makes any large allocation naturally aligned to its size. This means all alignment requests can be handled without checks.
The PAL API previously allowed for returning more memory than asked for. This was when the PAL performed the alignment work, now this is done in large alloc, so removing from the PAL.
On platforms that do not support aligned mmap/VirtualAlloc, we need to produce heavily aligned blocks to guarantee we can meet all possible alignment requests. This commit grabs a block much larger than requested, and then produces "offcuts" before and after the block of smaller/same "large_classes". This enables one mmap/virtual alloc request to services many other requests for aligned memory.
By turning page access on and off, we can simulate the Windows Commit/Decommit states on Posix platforms. This is just enabled in Debug for now.
#114 needs this. |
davidchisnall
approved these changes
Feb 5, 2020
davidchisnall
approved these changes
Feb 5, 2020
mjp41
added a commit
to mjp41/snmalloc-rs
that referenced
this pull request
Feb 7, 2020
`snmalloc` now supports alignment of all allocations with microsoft/snmalloc#124 This comment is no longer required.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This makes all large allocations aligned to their size next power of two size.
This introduces a new strategy for aligning blocks on platforms without a way to fetched aligned virtual memory (e.g. VirtualAlloc2, or mmap with MAP_ALIGNED).
To aid in debugging also uses mprotect to switch off unused pages in debug on posix platforms. This enables better testing of the Commit/Decommit code from Posix platforms.