Skip to content

perf(native): share equal inferred columns and guard custom rule CPU - #1074

Closed
kvlonge wants to merge 3 commits into
fix/native-analysis-session-speedfrom
fix/native-custom-rules-speed
Closed

kvlonge wants to merge 3 commits into
fix/native-analysis-session-speedfrom
fix/native-custom-rules-speed

Conversation

@kvlonge

@kvlonge kvlonge commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Why

Custom rules ran 1.2-1.3x slower (wall) under native-preview than python on the dense 3,000-model project. In CPU the gap was real: 1.151x (1794 vs 1559 ms, 5 alternating runs). Native session analyses built a new InferredColumn per model column, while Python's compact analysis shares one object per distinct column. The custom-rule host payload therefore pickled more distinct objects (64.0 MB vs 59.6 MB) and hosts decoded more.

Changes

  • NativeModelAnalysis keeps one InferredColumn per distinct column row for the session. Values are unchanged; only object identity is shared. Host payload is now 59.6 MB.
  • New custom_rules_cpu_ms: CPU of the custom-rule thread plus finished child processes (the rule hosts, via os.times; children are 0 on Windows).
  • Ratio tool reports it. New CI ratio entry gates custom_rules_cpu_ms at 1.25x python + 50 ms. The margin is wide because CI noise for this phase is unproven and the rule hosts share cores; the deterministic column-object count in the parity test is what pins the interning, so the gate only catches gross regressions.
  • Stacked on perf(native): share equal model analyses in the native session and guard their CPU #1073 for the ratio tool's engine and phase options.

Changed expectations, each new:

  • custom_rules_cpu_ms in compile JSON timing keys and in the dense cold E2E (> 0).
  • Ratio E2E case for the custom-rule phase.
  • Analysis parity: native column objects equal distinct column values (12 in the shared case; generated case asserts equality).

Verification

  • custom_rules_cpu_ms ratio, dense 3000, same machine: 1.151 before; after 1.007, 0.998, 0.996, 1.003, 1.005 (5 comparisons). The 1.144 sabotage is caught by the parity count, not this gate.
  • Sabotage, no sharing: ratio gate fails (1.144); parity fails (1863 objects vs 903 values; 54 vs 12).
  • Differential: 321 identical; deferrals unchanged.
  • Rule engine unit, ratio unit/E2E, compile JSON, analysis-session parity, seams and dense cold E2E tests; make check-ci; hygiene.

…d guard custom rule CPU

Native session analyses built a new InferredColumn per model column, while Python's compact
analysis shares one object per distinct column. Custom-rule hosts therefore pickled and decoded
more distinct objects under native-preview. Adds custom_rules_cpu_ms (rule thread plus host
children CPU) and a same-runner ratio entry for it.
@kvlonge

kvlonge commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Landed together in #1075 to cut merge-queue CI runs; review history stays here.

@kvlonge kvlonge closed this Oct 9, 2026
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