feat(memory): adopt mimalloc allocator - #2
Draft
randomvariable wants to merge 2 commits into
Draft
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Adopt mimalloc for Rust-owned heap allocations while preserving native allocator relief and process-level telemetry.
Stacked on cortexkit#283. Review only commits
692c81e2and36f6c668until cortexkit#283 merges.Changes
mi_collect(true)after idle eviction and from the detached allocator-maintenance threadmalloc_trim(0)on glibc andmalloc_zone_pressure_reliefon macOS for native libraries that bypass RustGlobalAllocCoverage 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
cargo check -p agent-file-tools --all-targetscargo fmt --all -- --checkgit diff --checkThe 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.