Skip to content

perf(compile): keep native analysis parallel at 10k models - #934

Merged
kvlonge merged 1 commit into
mainfrom
perf/native-analysis-parallel-10k
Oct 4, 2026
Merged

kvlonge merged 1 commit into
mainfrom
perf/native-analysis-parallel-10k

Conversation

@kvlonge

@kvlonge kvlonge commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Why

Native model analysis was forced to a single worker for projects with at least 10,000 models and 48 MiB of SQL, to save memory before the custom-rule hosts start. Measurement shows analysis is not where memory peaks: the peak comes later, in the rules phase. The cap left 3 of 4 cores idle at 10k (CHI-449).

Changes

  • Compact analysis always uses the full worker count; a unit test pins the decision.
  • The full-project native rules request is built, serialised and freed before evaluation, so its Python tree and JSON bytes no longer stay alive through the rules peak. Builder programming errors keep their traceback; values the JSON encoder rejects (such as enum integers beyond 64 bits) still become a clean C000 rules error.
  • Tighten the dense 10k peak-RSS guard from 4 GiB to 3.5 GiB.

Verification

  • Dense 10k --no-cache, 4 GiB cgroup (base → head): native analysis 5.8 → 1.3 s; main-process peak about 2.9 → 2.7 GB; whole process group 4.11 → 3.85 GB. Fingerprints match the pinned values at 3k/5k/10k.
  • Tests for worker count, builder-error propagation and encoder-error wrapping; oversized enum value reproduced through the real CLI.
  • One independent review plus follow-up; make test, make check-ci.

Drop the size heuristic that ran compact native analysis on one worker for
projects with at least 10,000 models and 48 MiB of SQL. Peak memory is set by
the rules phase, not analysis, so four workers do not raise it.

Build and serialize the native rules request before custom rules start and
outside the native error boundary, then release the request object tree and
its JSON bytes before native evaluation, removing two full-project copies from
the peak. Builder programming errors keep propagating unchanged.

Pin the worker decision and the builder error semantics with unit tests and
tighten the dense 10,000-model peak RSS budget from 4 GiB to 3.5 GiB.
@kvlonge
kvlonge enabled auto-merge (squash) October 4, 2026 05:09
@kvlonge
kvlonge merged commit ad29d02 into main Oct 4, 2026
30 checks passed
@kvlonge
kvlonge deleted the perf/native-analysis-parallel-10k branch October 4, 2026 05:32
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