Skip to content

feat(memory): adopt mimalloc allocator - #2

Draft
randomvariable wants to merge 2 commits into
priorityqueuefrom
memory-mimalloc
Draft

feat(memory): adopt mimalloc allocator#2
randomvariable wants to merge 2 commits into
priorityqueuefrom
memory-mimalloc

Conversation

@randomvariable

Copy link
Copy Markdown
Owner

Purpose

Adopt mimalloc for Rust-owned heap allocations while preserving native allocator relief and process-level telemetry.

Stacked on cortexkit#283. Review only commits 692c81e2 and 36f6c668 until cortexkit#283 merges.

Changes

  • install mimalloc as the Rust global allocator in production and allocation-counted tests
  • derive Rust allocator requested, committed, and retained-byte telemetry from mimalloc statistics
  • run mi_collect(true) after idle eviction and from the detached allocator-maintenance thread
  • retain malloc_trim(0) on glibc and malloc_zone_pressure_relief on macOS for native libraries that bypass Rust GlobalAlloc
  • preserve the fleet health memory field names and byte units
  • document the allocator coverage boundary
  • add a realistic multi-root daemon comparison protocol for cold build, steady serving, idle eviction, and post-relief residency

Coverage boundary

mimalloc statistics cover Rust-owned heap allocations. SQLite, tree-sitter, ONNX Runtime, and other native libraries can still allocate through the platform allocator. RSS, macOS physical footprint, SQLite bytes, and subsystem estimates remain independent process checks.

Verification

  • allocator relief contracts passed
  • fleet health payload compatibility contracts passed
  • cargo check -p agent-file-tools --all-targets
  • cargo fmt --all -- --check
  • git diff --check

The realistic multi-root benchmark protocol is committed without results. Both allocator arms still require paired representative-host runs before an allocator performance claim.

Scope

This PR changes allocator ownership and reclamation only. Explicit subsystem budgets, charge-before-build admission, and cache eviction policy remain separate work.

Contribution

AI-assisted implementation and verification with OpenAI Codex through Oh My Pi. The author reviewed the changes and test evidence.

randomvariable and others added 2 commits August 31, 2026 17:31
Signed-off-by: Naadir Jeewa <naadir@randomvariable.co.uk>
Co-authored-by: alfonso-aft <289616620+alfonso-aft@users.noreply.github.com>
Signed-off-by: Naadir Jeewa <naadir@randomvariable.co.uk>
Co-authored-by: alfonso-aft <289616620+alfonso-aft@users.noreply.github.com>
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.

1 participant