-
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
Optimise the fast path for alloc and dealloc #62
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 massively improves the TLS access at the expense of not being dynamically loadable.
This is useful as codegen is nicer if we use size_t, but the semantics is uint8_t, and is stored as that in many places in the metadata. Ultimately should introduce a wrapper to check this invariant.
This change introduces a per small sizeclass free list. That can be used to access the free objects for that sizeclass with minimal calculations being required. It changes to a partial bump ptr. We bump allocate a whole OS page worth of objects at a go, so we don't switch as frequently between bump and free list allocation. The code for the fast paths has been restructured to minimise the work required on the common case, and also it is all inlined for the common case. Allocating a zero sized object is moved off the fast path. Ask for 1 byte if you want to be fast.
Fixes GCC warning that was incorrect using an ASSUME. Made fast path and slow path Macros so we can add additional attributes.
This addresses #58 |
bool valid_head(bool is_short) | ||
{ | ||
size_t size = sizeclass_to_size(sizeclass); | ||
size_t slab_start = get_initial_link(sizeclass, is_short); | ||
size_t slab_start = get_initial_offset(sizeclass, is_short); | ||
size_t all_high_bits = ~static_cast<size_t>(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't we have a constant for this expression?
Removed stub from message queue, and use an actual allocation.
mjp41
commented
Jul 2, 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just pushed changes that I think address @davidchisnall s comments
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 seems to have a pretty drastic improvement in speed to heavy allocation benchmarks. It pushes
snmalloc
to have approximately the same performance asmimalloc
on thecfrac
benchmark.