Skip to content

isolated_alloc: directly use mmap for allocations #4362

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nia-e
Copy link
Contributor

@nia-e nia-e commented May 31, 2025

In case there isn't a resolution to #4357, this will fix it at least. Benchmark with the allocator force-enabled vs baseline:

Comparison with baseline (relative speed, lower is better for the new results):
  backtraces: 1.10 ± 0.06
  big-allocs: 0.94 ± 0.07
  mse: 0.96 ± 0.03
  range-iteration: 0.99 ± 0.05
  serde1: 1.03 ± 0.05
  serde2: 1.02 ± 0.05
  slice-chunked: 0.99 ± 0.04
  slice-get-unchecked: 0.93 ± 0.04
  string-replace: 0.84 ± 0.04
  unicode: 1.03 ± 0.04
  zip-equal: 0.95 ± 0.07

@nia-e nia-e force-pushed the fix-alloc-perf branch from 1a391cb to 339d7fc Compare May 31, 2025 09:04
@@ -60,12 +60,13 @@ impl IsolatedAlloc {

/// If the allocation is greater than a page, then round to the nearest page #.
#[inline]
fn huge_normalized_layout(layout: Layout, page_size: usize) -> Layout {
fn huge_normalized_layout(&self, layout: Layout, page_size: usize) -> (Layout, usize) {
Copy link
Member

Choose a reason for hiding this comment

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

This is odd, since the resulting Layout is not what we are actually using -- we can't even tell mmap an alignment.

So really the "number of pages to allocate" is the only thing this should return I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made it return the size directly instead of page count since that's what we use, but good point. Also got rid of the page_layout function since we only care about the size when mmapping

@nia-e nia-e force-pushed the fix-alloc-perf branch from 394a9e7 to fdf03ed Compare June 1, 2025 19:59
@nia-e nia-e force-pushed the fix-alloc-perf branch from fdf03ed to 42afab6 Compare June 1, 2025 23:42
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