feat: Add allocation_hints and rallocator - #638
feat: Add allocation_hints and rallocator#638Ralf Biedert (ralfbiedert) wants to merge 6 commits into
allocation_hints and rallocator#638Conversation
✅ Version increments look sufficient
|
There was a problem hiding this comment.
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_hintsinfrastructure for domains/heaps/scoped hints and backend registration. - Add
rallocatorglobal allocator with tunables/config macros, platform HALs (Linux/Windows/Miri), telemetry API surface, tests, examples, and benchmarks. - Add
rallocator_wire,rallocator_telemetry, andrallocator_clifor 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.
martintmk
left a comment
There was a problem hiding this comment.
[Copilot speaking]
I found four correctness defects in legacy decoding, malformed-input handling, and the Miri free-list model. Verdict: changes requested.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
SendAddressis documented as transporting ownership across threads, but it is markedCopy, which allows accidental duplication of the pointer value and makes the ownership/unique-free invariant unenforceable. Making the wrapper non-Copybetter matches the safety comment and reduces the risk of accidental double-free in future edits.
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>
e085c1c to
1cb07dd
Compare
There was a problem hiding this comment.
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
rallocatorcommand, but this crate israllocator_cli(and main.rs/docs/tests refer torallocator_cli). This looks like a copy/paste mismatch in public-facing docs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
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_lenis read as au32but cast tousizewithas, which can silently truncate on targets whereusizeis smaller than 32 bits. Use a fallible conversion and surfaceError::LENGTH_OVERFLOW(matchingWriter::begin_section).
Codecov Report❌ Patch coverage is ❌ 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
No description provided.