Skip to content

perf(cli): ship mimalloc in the production feature - #1751

Merged
ScriptedAlchemy merged 1 commit into
masterfrom
perf/mimalloc-default
Sep 18, 2026
Merged

ScriptedAlchemy merged 1 commit into
masterfrom
perf/mimalloc-default

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

Why an allocator change is the root-cause fix, not a mask

Every previous fix (#1570 token clones, \b DFA, #1594 arena cap) shared one premise: glibc malloc is the allocator and the code should compensate for it. The census on the live daemon showed glibc has no setting that fits this workload:

glibc setting CPU Memory
MALLOC_ARENA_MAX=2 (the unit's old cap) 60% of daemon CPU in __pv_queued_spin_lock_slowpath under __lll_lock_wait_private; status took 30.6 s waiting on admission 15 GB RSS
default (cap removed, #1594) lock share 4.7% 18.4 GB RSS of which 14.3 GB was 747 glibc arena mappings holding freed heap; RSS never came down

Admission trusts measured RSS (resident_memory.rs), so with glibc the resident-memory policy refused graph activation permanently after one warm peak — the "code graph activation was refused by the resident-memory policy" behind 47 tool refusals in the dogfood run.

Measured under mimalloc (same host, same 12 projects, same source)

  • Lock share: noise. status tool 30.6 s → 0.14 s.
  • RSS peak unchanged (~18 GB — that is live working set during the multi-project warm, a separate problem), but RSS returns: 12.3 → 8.4 GB between phases, 13.2 GB at 90 minutes vs glibc pinned at 18.4. Graph activation went from refused to pending/proceeding.

Change

production = ["tracedecay/production", "alloc-mimalloc"]. Release builds use --no-default-features --features production, so this is the shipped allocator on all four targets (verified: the release-profile build links mi_*). Precedence for overlapping features is unchanged (hotpath-alloc > jemalloc > mimalloc). No code change; malloc_trim reclaimer stays a harmless no-op under mimalloc as its comment already states.

Not chosen: jemalloc (tikv-jemallocator has no MSVC support; Windows is a release target).

glibc malloc has no setting that fits a daemon indexing on dozens of worker
threads. Measured on beta.41 warming 12 projects: two arenas put 60% of
daemon CPU into arena locks; unlimited arenas held 14 GB of freed heap out of
18 GB RSS, and because admission trusts measured RSS the graph never
activated again after one peak. Under mimalloc on the same host and corpus
the lock share fell to noise and RSS followed live data, 8-13 GB between
phases with the same peak, so the resident-memory refusal clears on its own.
The production feature now selects alloc-mimalloc, which builds on all four
release targets.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@ScriptedAlchemy
ScriptedAlchemy merged commit c183290 into master Sep 18, 2026
4 of 7 checks passed
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