Skip to content
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

Startup improvements #639

Merged
merged 18 commits into from
Sep 28, 2023
Merged

Startup improvements #639

merged 18 commits into from
Sep 28, 2023

Conversation

mjp41
Copy link
Member

@mjp41 mjp41 commented Sep 27, 2023

This PR improves the startup cost of snmalloc.

It adds a benchmark for profiling startup by starting a lot of threads, waiting for them to reach a stable point, each perform a single allocation deallocation pair, and terminate. It measure the time taken from all threads starting allocation until the last one has completed its deallocation.

The second commit makes the Pool pass the spare memory in a meta-data allocation to the constructor of that type. This is then used to seed the local state in the backend with a small amount of meta-data, and means the first allocation does not need to request more meta-data memory.

The benchmark goes from taking ~2.5M cycles to ~1.3M cycles for the checked build, and ~1.4M cycles to ~1.1M cycles for the fast build (wall clock cycles).

The pool will result in power of 2 allocations as it doesn't have a
local state when it is initially set up.

This commit passes this extra space to the constructor of the pooled
type, so that it can be feed into the freshly created allocator.
src/snmalloc/mem/pool.h Outdated Show resolved Hide resolved
src/snmalloc/aal/aal.h Outdated Show resolved Hide resolved
Co-authored-by: Nathaniel Wesley Filardo <nfilardo@microsoft.com>
Copy link
Contributor

@nwf-msr nwf-msr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite the comment I just raised, I think this is good to go as it stands.

@mjp41 mjp41 merged commit 5543347 into microsoft:main Sep 28, 2023
49 checks passed
@mjp41 mjp41 deleted the startup_improvements branch September 28, 2023 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants