Skip to content

feat: Add allocation_hints and rallocator - #638

Open
Ralf Biedert (ralfbiedert) wants to merge 6 commits into
mainfrom
u/ralfbiedert/rallocator
Open

feat: Add allocation_hints and rallocator#638
Ralf Biedert (ralfbiedert) wants to merge 6 commits into
mainfrom
u/ralfbiedert/rallocator

Conversation

@ralfbiedert

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI lite review requested due to automatic review settings August 4, 2026 16:07
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

✅ Version increments look sufficient

cargo semver-checks compared the 5 crate(s) this PR publishes against their previous version-bump commit in git history. Every version increment is sufficient for the detected API changes.

Crate Baseline Baseline commit This PR Minimum required Status
allocation_hints new crate 0.1.0 0.1.0 ✅ ok
rallocator new crate 0.1.0 0.1.0 ✅ ok
rallocator_cli new crate 0.1.0 0.1.0 ✅ ok
rallocator_telemetry new crate 0.1.0 0.1.0 ✅ ok
rallocator_wire new crate 0.1.0 0.1.0 ✅ ok

This check is informational and does not block the merge.

View the check run

Comment thread crates/rallocator/src/heap/bump/state.rs Dismissed
Comment thread crates/rallocator/src/heap/bump/state.rs Dismissed
Comment thread crates/rallocator/src/heap/mod.rs Fixed
Comment thread crates/rallocator/src/telemetry/core.rs Dismissed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new allocator stack built around allocation_hints + rallocator, plus a telemetry snapshot schema/wire format and a CLI tool to render snapshots as HTML reports. It adds the core allocator implementation, configuration/tuning macros, OS/Miri HAL backends, extensive tests/benches, and the supporting telemetry crates.

Changes:

  • Add allocation_hints infrastructure for domains/heaps/scoped hints and backend registration.
  • Add rallocator global allocator with tunables/config macros, platform HALs (Linux/Windows/Miri), telemetry API surface, tests, examples, and benchmarks.
  • Add rallocator_wire, rallocator_telemetry, and rallocator_cli for snapshot encoding/decoding and HTML reporting; wire these crates into the workspace.

Reviewed changes

Copilot reviewed 76 out of 78 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
crates/rallocator/tests/tls_teardown.rs Adds a TLS-destructor regression test ensuring allocator usability during teardown.
crates/rallocator/tests/multithreaded.rs Adds multithreaded allocator stress tests (cross-thread frees, alignment, reuse).
crates/rallocator/tests/global_allocator.rs Exercises global allocator + hinted heaps + retirement/unmapping behavior.
crates/rallocator/tests/allocator.rs Adds direct Rallocator instance tests for size classes, slabs, spans, coalescing, stats.
crates/rallocator/src/tunables.rs Introduces tunables traits, standard size classes, and tunable! macro + table builders.
crates/rallocator/src/telemetry/stats.rs Exposes public telemetry stats types via re-export.
crates/rallocator/src/telemetry/snapshot.rs Exposes public snapshot type via re-export.
crates/rallocator/src/telemetry/mod.rs Adds telemetry module wiring and public API exports.
crates/rallocator/src/lib.rs Adds crate docs, exports, and the rallocator! global allocator macro.
crates/rallocator/src/heap/mod.rs Implements allocation_hints backend integration and heap creation/inspection hooks.
crates/rallocator/src/heap/bump/mod.rs Adds bump heap module plumbing.
crates/rallocator/src/hal/win64.rs Adds Windows x86_64 HAL for mapping, decommit/unmap, time, and stack capture.
crates/rallocator/src/hal/native.rs Adds non-Miri generic/native HAL helpers/constants.
crates/rallocator/src/hal/mod.rs Adds platform selection, fault injection for tests, and HAL API surface.
crates/rallocator/src/hal/miri.rs Adds a Miri-friendly HAL implementation with remote-free metadata simulation.
crates/rallocator/src/hal/linux.rs Adds Linux x86_64 HAL (mmap/mprotect/madvise/munmap, stack capture).
crates/rallocator/src/domain/mod.rs Adds domain creation/default-domain wiring for allocation_hints backend.
crates/rallocator/src/config/mod.rs Introduces config trait + config! macro for compile-time telemetry/tunables selection.
crates/rallocator/README.md Auto-generated crate README derived from crate docs.
crates/rallocator/examples/allocation_tracking.rs Adds example showing caller tracking + snapshot writing.
crates/rallocator/Cargo.toml Defines the rallocator crate, features, dependencies, benches.
crates/rallocator/benches/workloads/mod.rs Adds synthetic workloads for allocator benchmarking.
crates/rallocator/benches/tracking_none.rs Bench harness for baseline (no tracking).
crates/rallocator/benches/tracking_callers_capable.rs Bench harness enabling caller tracking capability.
crates/rallocator/benches/tracking_all.rs Bench harness enabling aggregates + callers.
crates/rallocator/benches/tracking_all_callers.rs Bench harness enabling tracking and turning callers on at runtime.
crates/rallocator/benches/tracking_aggregates.rs Bench harness enabling aggregate stats only.
crates/rallocator/benches/rallocator.rs Bench harness using rallocator with default config.
crates/rallocator/benches/ordinary_workloads/mod.rs Adds “ordinary” container workloads used by bump/system benches.
crates/rallocator/benches/mimalloc.rs Bench harness using mimalloc global allocator.
crates/rallocator/benches/bump_workloads/mod.rs Adds bump-style workload suite and noise generator utilities.
crates/rallocator/benches/bump_system.rs Runs bump workloads on the system allocator.
crates/rallocator/benches/bump_rallocator.rs Runs bump workloads on rallocator (explicit bump heaps).
crates/rallocator/benches/bump_rallocator_global.rs Runs bump workloads on rallocator installed globally.
crates/rallocator/benches/bump_multitude.rs Runs bump workloads on multitude arena implementation.
crates/rallocator/benches/bump_mimalloc.rs Runs bump workloads on mimalloc global allocator.
crates/rallocator_wire/tests/wire.rs Adds tests for wire header/sections, malformed input rejection, writer invariants.
crates/rallocator_wire/src/lib.rs Adds no-std wire encoding traits + error type.
crates/rallocator_wire/src/io.rs Implements allocation-free reader/writer for the wire format.
crates/rallocator_wire/src/format.rs Defines wire container/header/section format types + magic/version.
crates/rallocator_wire/README.md Auto-generated crate README for wire format primitives.
crates/rallocator_wire/Cargo.toml Defines the rallocator_wire crate.
crates/rallocator_telemetry/src/topology.rs Adds owned topology model types (regions/slices/segments).
crates/rallocator_telemetry/src/snapshot.rs Adds owned snapshot schema types (stats, domains, histograms, metadata).
crates/rallocator_telemetry/src/callers.rs Adds retained caller/symbol model types.
crates/rallocator_telemetry/README.md Auto-generated crate README for telemetry schema/encoding.
crates/rallocator_telemetry/Cargo.toml Defines the rallocator_telemetry crate.
crates/rallocator_cli/tests/support/mod.rs Integration-test helper to render snapshots via CLI and read HTML output.
crates/rallocator_cli/tests/render_migration.rs HTML rendering tests covering legacy/migration scenarios and detailed topology/callers.
crates/rallocator_cli/tests/render_html.rs End-to-end HTML report content/structure assertions.
crates/rallocator_cli/tests/cli.rs CLI integration tests for snapshot html command behavior and error reporting.
crates/rallocator_cli/src/templates/snapshot.html Adds the HTML template (CSS/JS) used by the CLI report generator.
crates/rallocator_cli/src/main.rs Adds clap-based CLI entry point and command routing.
crates/rallocator_cli/src/commands/snapshot/mod.rs Adds snapshot command module wiring.
crates/rallocator_cli/src/commands/snapshot/html.rs Implements snapshot html verb: read/decode/write report, print output path.
crates/rallocator_cli/src/commands/mod.rs Adds CLI command module wiring.
crates/rallocator_cli/README.md Auto-generated crate README for the CLI tool.
crates/rallocator_cli/Cargo.toml Defines the rallocator_cli crate and dependencies.
crates/allocation_hints/src/heap/general.rs Adds general heap options/info/usage model types and validation.
crates/allocation_hints/src/heap/bump.rs Adds bump heap options/info/usage model types and validation.
crates/allocation_hints/src/domain.rs Adds process-retained domain wrapper and backend installation probe.
crates/allocation_hints/src/backend.rs Adds backend registry + raw hint/domain/heap targets and backend contract.
crates/allocation_hints/README.md Auto-generated crate README for allocation hint infrastructure.
crates/allocation_hints/Cargo.toml Defines the allocation_hints crate.
Cargo.toml Adds workspace dependencies and registers new local crates.
Cargo.lock Locks new dependencies and adds new workspace crates to the lockfile.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/rallocator/src/hal/linux.rs Outdated
Comment thread crates/rallocator/src/heap/mod.rs
Comment thread crates/rallocator/src/domain/mod.rs
Comment thread crates/allocation_hints/src/heap/mod.rs Outdated
Comment thread crates/rallocator/src/heap/mod.rs
Comment thread crates/rallocator/src/heap/mod.rs Outdated
Comment thread crates/rallocator_cli/src/commands/snapshot/html.rs Outdated
Comment thread crates/rallocator/src/heap/mod.rs
Comment thread crates/rallocator/src/allocator.rs
Comment thread crates/allocation_hints/src/lib.rs
Comment thread crates/allocation_hints/src/heap/mod.rs
Comment thread crates/allocation_hints/src/lib.rs
Comment thread crates/rallocator/src/hal/mod.rs
Comment thread crates/rallocator/src/config/mod.rs
Comment thread crates/rallocator_telemetry/src/snapshot.rs
Comment thread crates/rallocator_telemetry/src/lib.rs
Comment thread crates/allocation_hints/src/heap/mod.rs
Comment thread Cargo.toml
Comment thread crates/rallocator/Cargo.toml Outdated
Comment thread crates/rallocator/examples/allocation_tracking.rs Outdated
Comment thread crates/rallocator_cli/src/main.rs Outdated
Comment thread crates/rallocator/src/allocator.rs
Comment thread crates/rallocator/benches/workloads/mod.rs Outdated
Comment thread crates/rallocator_cli/src/report.rs Outdated
Comment thread crates/rallocator/examples/allocation_tracking.rs Outdated
Comment thread crates/rallocator/examples/allocation_tracking.rs Outdated
Comment thread crates/rallocator/examples/allocation_tracking.rs

@martintmk martintmk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[Copilot speaking]

I found four correctness defects in legacy decoding, malformed-input handling, and the Miri free-list model. Verdict: changes requested.

Comment thread crates/rallocator_telemetry/src/lib.rs Outdated
Comment thread crates/rallocator_telemetry/src/lib.rs Outdated
Comment thread crates/rallocator/src/hal/miri.rs
Comment thread crates/rallocator/src/allocator.rs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 83 out of 85 changed files in this pull request and generated no new comments.

Suppressed comments (2)

crates/rallocator/benches/rallocator_threaded.rs:8

  • Duplicate module-level doc comments (same sentence repeated) add noise in rustdoc and can confuse grep/search results. Keep a single //! line.
//! Multithreaded allocation benchmarks using rallocator.

//! Multithreaded allocation benchmark using rallocator.

crates/rallocator/benches/rallocator_threaded_mimalloc.rs:8

  • Duplicate module-level doc comments (same sentence repeated) add noise in rustdoc and can confuse grep/search results. Keep a single //! line.
//! Multithreaded allocation benchmarks using mimalloc.

//! Multithreaded allocation benchmark using mimalloc.

Comment thread crates/rallocator/tests/telemetry.rs
Copilot AI review requested due to automatic review settings August 7, 2026 13:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 83 out of 85 changed files in this pull request and generated no new comments.

Suppressed comments (3)

crates/rallocator/benches/rallocator_threaded.rs:7

  • The crate-level doc comment is duplicated, which will produce redundant Rustdoc output and looks unintentional. Keep only one of the two identical //! lines.
//! Multithreaded allocation benchmarks using rallocator.

//! Multithreaded allocation benchmark using rallocator.

crates/rallocator/benches/rallocator_threaded_mimalloc.rs:7

  • The crate-level doc comment is duplicated, which will produce redundant Rustdoc output and looks unintentional. Keep only one of the two identical //! lines.
//! Multithreaded allocation benchmarks using mimalloc.

//! Multithreaded allocation benchmark using mimalloc.

crates/rallocator/tests/multithreaded.rs:31

  • SendAddress is documented as transporting ownership across threads, but it is marked Copy, which allows accidental duplication of the pointer value and makes the ownership/unique-free invariant unenforceable. Making the wrapper non-Copy better matches the safety comment and reduces the risk of accidental double-free in future edits.

Comment thread crates/rallocator/src/allocator.rs
Comment thread crates/rallocator/src/allocator.rs
Comment thread crates/rallocator/src/allocator.rs Outdated
Comment thread crates/rallocator/src/telemetry/core.rs Outdated
Comment thread crates/rallocator_telemetry/src/snapshot.rs Outdated
Comment thread crates/rallocator_telemetry/src/lib.rs Outdated
Comment thread crates/allocation_hints/src/lib.rs
Comment thread crates/rallocator/src/hal/linux.rs Outdated
Comment thread crates/rallocator/src/tunables.rs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 7, 2026 17:04
Comment thread crates/rallocator/src/hal/linux.rs Dismissed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 83 out of 85 changed files in this pull request and generated no new comments.

Suppressed comments (3)

crates/rallocator/benches/rallocator_threaded_mimalloc.rs:9

  • Duplicate crate-level doc comment; the //! line is repeated verbatim. Remove the redundant copy to avoid duplicated rustdoc output.
//! Multithreaded allocation benchmarks using mimalloc.

//! Multithreaded allocation benchmark using mimalloc.

mod rallocator_threaded_workloads;

crates/rallocator/benches/rallocator_threaded.rs:8

  • Duplicate crate-level doc comment; having two nearly identical //! lines is confusing and likely unintended. Remove the redundant second line.
//! Multithreaded allocation benchmarks using rallocator.

//! Multithreaded allocation benchmark using rallocator.

mod rallocator_threaded_workloads;

crates/rallocator_cli/src/report.rs:15

  • The module-level docs say this is for the rallocator command, but this crate is rallocator_cli (and main.rs/docs/tests refer to rallocator_cli). This looks like a copy/paste mismatch in public-facing docs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 7, 2026 17:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 83 out of 85 changed files in this pull request and generated no new comments.

Suppressed comments (3)

crates/rallocator/benches/rallocator_threaded.rs:8

  • Duplicate crate-level doc comments; the second line repeats the benchmark description and should be removed to avoid redundant rendered docs.
//! Multithreaded allocation benchmarks using rallocator.

//! Multithreaded allocation benchmark using rallocator.

mod rallocator_threaded_workloads;

crates/rallocator/benches/rallocator_threaded_mimalloc.rs:8

  • Duplicate crate-level doc comments; the second line repeats the benchmark description and should be removed to avoid redundant rendered docs.
//! Multithreaded allocation benchmarks using mimalloc.

//! Multithreaded allocation benchmark using mimalloc.

mod rallocator_threaded_workloads;

crates/rallocator_wire/src/io.rs:156

  • payload_len is read as a u32 but cast to usize with as, which can silently truncate on targets where usize is smaller than 32 bits. Use a fallible conversion and surface Error::LENGTH_OVERFLOW (matching Writer::begin_section).

@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.18776% with 122 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.7%. Comparing base (9513482) to head (fef10f1).

Files with missing lines Patch % Lines
crates/allocation_hints/src/backend.rs 61.0% 23 Missing ⚠️
crates/rallocator_telemetry/src/lib.rs 97.1% 23 Missing ⚠️
crates/allocation_hints/src/lib.rs 94.1% 19 Missing ⚠️
crates/rallocator/src/hal/linux.rs 92.1% 9 Missing ⚠️
crates/rallocator_wire/src/lib.rs 52.6% 9 Missing ⚠️
crates/rallocator/src/heap/mod.rs 95.6% 8 Missing ⚠️
crates/rallocator/src/telemetry/core.rs 99.4% 8 Missing ⚠️
crates/rallocator/src/heap/bump/state.rs 99.1% 6 Missing ⚠️
crates/rallocator_cli/src/report.rs 99.3% 6 Missing ⚠️
crates/rallocator/src/tuning_telemetry.rs 99.3% 4 Missing ⚠️
... and 5 more

❌ Your project check has failed because the head coverage (99.7%) is below the target coverage (100.0%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff            @@
##             main    #638      +/-   ##
=========================================
- Coverage   100.0%   99.7%    -0.3%     
=========================================
  Files         473     501      +28     
  Lines       45493   56014   +10521     
=========================================
+ Hits        45493   55882   +10389     
- Misses          0     132     +132     
Flag Coverage Δ
windows 98.7% <98.2%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

5 participants