You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(install): attested --frozen no-op fixed cost after #5423 (Linux t10 CPU 0.97 s, Windows 1.41 s) #5491
performanceLegacy classification name; prefer type/performance. Retained for history.status/needs-triageAwaiting a human scope decision, including after automated advice.type/performanceLatency, throughput, memory, install time.
Follow-up to #5423 (#4770). On Linux at tree-10, the attested install --frozen no-op meets the <= 1 s CPU bar with only a ~3% margin. On Windows it stays over the bar.
Evidence
Main f68cebd vs #5423 head 7a88c66, RTT 30 ms, 15 pairs, output "same" in every cell:
The plain no-op replay (install-noop) is 0.878 s CPU on Linux at tree-10.
Attribution. The pre-rebase head 82eb6cb and the rebased head 7a88c66 measure the same: 0.967 vs 0.963 s CPU, paired 1.004 (45629828825). The rebase onto main added no cost. The lower figure measured earlier (0.857 s at 2eff8ab vs main 1e4a208, run 45550882169) is therefore unconfirmed. It comes from an older base and a different runner sample.
Profile (one cProfile sample, new side, Linux t10; profiler-inflated)
Cumulative time inside fast_entry._run, 1.19 s:
Imports: about 0.79 s cumulative. The codex_plugins import chain (registrar -> admission -> manifest -> plugin_parser -> bundle) is about 0.175 s. diff_apply._refuse_native_* pulls it in. Import-time dataclass creation is about 0.33 s.
InstallService.enforce_frozen runs twice, about 0.23 s for both. One run is the fast-path preflight (verdict_attest.refuse_frozen_drift). The other is the render's parity preflight (fast_output._frozen_preflight, W3d AF4). Each call recomputes _frozen_mcp_reasons, about 0.16 s for both.
LockFile.read runs 13 times, about 0.21 s. YAML load runs 62 times, about 0.18 s.
mcp_config_view.select / derive run 4 times, about 0.26 s.
Candidate levers (to be designed and gated, not decided here)
Run the frozen preflight once per run and reuse its result for the parity render, keeping AF4's print point.
Parse the lockfile once per run on the fast path.
Defer the codex_plugins / bundle imports out of _refuse_native_* when no native plugin is locked.
On Windows, the ~1.4 s t10 fixed cost needs its own profile (PROFILE=1 is not supported on Windows runners today).
Correction to the lever 2 framing: the cost is not the 13 reads themselves. The YAML parse of apm.lock.yaml is already memoized (lockfile_container.parse_lockfile_text), so a repeat LockFile.read costs about 3.5 ms. A copy-on-read object memo would cost more (a deepcopy takes about 4.2 ms). The measurable repeat cost inside those reads was warn_if_newer -> installed_apm_version -> get_version, which scanned the installed distributions via importlib.metadata.version 16 times per run. #5496 memoizes that lookup per process, keyed on the lookup callable. Rows: Linux 45639586174, Windows 45639602441; CPU 1.00x-1.04x in all 8 cells, output "same".
Lever 4 scope note (no code yet): mcp_config_view.select x4
Profile: one cProfile sample of the attested install --frozen hit, tree-10, Linux, before #5493. cProfile inflates times about 1.5x against the 0.97 s real CPU.
Where the calls come from.CurrentMcpConfigView.select -> derive -> _collect_locked_dependencies runs 4 times, 0.257 s cumulative:
1 in fast_output.check_merged_mcp, the fast mirror of the full run's silent commit-gate pre-pass (commit_gate._prepare_merged_mcp).
1 in service_integration.run_service_integrations -> prepare_mcp_integration (the MCP phase).
Per call, the cost is mostly re-reading the locked packages' apm.yml: across the 4 calls, 40 yaml_io.load_yaml (0.065 s) plus 40 APMPackage.from_mapping (0.040 s). Trust admission adds McpAdmission.admit (8 calls, 0.055 s, part of it first-call import).
Option A (the lever as ordered): one admitted view for the commit gate and the MCP phase. Reuse the pre-pass's PreparedMcpIntegration in run_service_integrations.
Invariant: the same admitted set, the same omission evidence, the same trust notices at the same points, and the same parked or blocked verdicts.
Files: install/commit_gate.py, install/service_integration.py, install/mcp/integration.py, install/fast_output.py, and the full pipeline's caller.
Risk: it changes the full pipeline's trust admission. The two passes differ today: silent logger vs real logger, recorded=None, diagnostics, and dry_run policy refusal. A shared view must prove that each difference is output-only.
Expected saving: one select on the hit, about 0.045 s profiled, so about 30 ms real, about 3% of frozen t10 CPU.
Option B (alternative, no admission change): memoize the locked-manifest parse per process. Key it on the bytes of each locked package's apm.yml read in _collect_locked_dependencies, returning a fresh APMPackage per call. Admission still runs on every pass.
Invariant: byte-identical input gives an identical parse. Nothing about trust changes.
Files: integration/mcp_config_view.py, plus possibly the APMPackage.from_apm_yml cache owner.
Expected saving: the YAML parse of the 2nd and 3rd reads of each manifest, about 2 x 0.026 s profiled, so about 35 ms real, about 3.5%. This needs a measurement, because from_mapping per call may remain.
Recommendation. Option A is at the ~3% kill line and carries the higher trust risk. I recommend killing A on this note. Option B, if pursued, should be a separate small lever with its own row and a W3b pre-read, since it touches what the MCP view reads.
Lever 4 Option A (one admitted MCP view shared by the commit gate and the MCP phase) is killed by the PERF VP ruling (17:25 CET): it changes full-pipeline trust admission for about 3% CPU. Option B (a per-process, byte-keyed memo of the locked package apm.yml parse, returning a fresh object, with admission unchanged) is approved as lever 4b, with its own stacked PR, row, S93 and W3b review.
Lever 4b (#5501, a byte-keyed manifest parse memo) is killed by the regent ruling: at c5e21db only 1 cell met the bar (CPU >= 1.03x with paired outside +/-2%). L5 and L6 are restacked on #5499.
L5 (lazy apm_cli.integration exports, PEP 562) is killed. Row 45661949383 (15 pairs, output "same"): install-warm regresses to 0.97x CPU at t10 (1.372 -> 1.418) and t50 (4.478 -> 4.612, paired 1.026), against no-op gains of 1.00x-1.03x. The bar for pure-redundancy levers allows no regressing cell. On the attested hits it dropped 34 modules, but a journey that loads every integrator anyway cannot gain from laziness: the 11-25 lesson held again. Branch danielmeppiel-perf-5491-lazy-integration is deleted (no PR was opened).
Verdicts. All rows are 15-pair CI benches (3 runners x 5 pairs), RTT 30 ms, with output "same" in every cell. Each number is CPU p50 speedup, with paired wall new/base in parentheses.
The Linux tree-10 frozen no-op CPU p50 is 0.909 s, under #4770's <= 1 s bar. On Windows, t10 is 1.23 s.
What remains. The rest of the frozen hit is dominated by imports of modules it actually executes (the 11-25 lesson; L5 confirmed it on warm). No further lever is open under this issue. #5493 -> #5496 -> #5499 land as a stack after #5423.
performanceLegacy classification name; prefer type/performance. Retained for history.status/needs-triageAwaiting a human scope decision, including after automated advice.type/performanceLatency, throughput, memory, install time.
Activity
perf(install): fold W3d N1/N2 on the frozen preflight tape (#5491)
fix(install): the preflight tape is matched by exact type; full runs …
danielmeppiel commentedon Nov 25, 2026
Correction to the lever 2 framing: the cost is not the 13 reads themselves. The YAML parse of
apm.lock.yamlis already memoized (lockfile_container.parse_lockfile_text), so a repeatLockFile.readcosts about 3.5 ms. A copy-on-read object memo would cost more (a deepcopy takes about 4.2 ms). The measurable repeat cost inside those reads waswarn_if_newer->installed_apm_version->get_version, which scanned the installed distributions viaimportlib.metadata.version16 times per run. #5496 memoizes that lookup per process, keyed on the lookup callable. Rows: Linux 45639586174, Windows 45639602441; CPU 1.00x-1.04x in all 8 cells, output "same".danielmeppiel commentedon Nov 25, 2026
Lever 4 scope note (no code yet):
mcp_config_view.selectx4Profile: one cProfile sample of the attested
install --frozenhit, tree-10, Linux, before #5493. cProfile inflates times about 1.5x against the 0.97 s real CPU.Where the calls come from.
CurrentMcpConfigView.select->derive->_collect_locked_dependenciesruns 4 times, 0.257 s cumulative:InstallService._frozen_mcp_reasons(the frozen preflight). perf(install): the attested --frozen hit judges the frozen preflight once (#5491) #5493 drops these to 1.fast_output.check_merged_mcp, the fast mirror of the full run's silent commit-gate pre-pass (commit_gate._prepare_merged_mcp).service_integration.run_service_integrations->prepare_mcp_integration(the MCP phase).Per call, the cost is mostly re-reading the locked packages'
apm.yml: across the 4 calls, 40yaml_io.load_yaml(0.065 s) plus 40APMPackage.from_mapping(0.040 s). Trust admission addsMcpAdmission.admit(8 calls, 0.055 s, part of it first-call import).Option A (the lever as ordered): one admitted view for the commit gate and the MCP phase. Reuse the pre-pass's
PreparedMcpIntegrationinrun_service_integrations.install/commit_gate.py,install/service_integration.py,install/mcp/integration.py,install/fast_output.py, and the full pipeline's caller.recorded=None,diagnostics, anddry_runpolicy refusal. A shared view must prove that each difference is output-only.selecton the hit, about 0.045 s profiled, so about 30 ms real, about 3% of frozen t10 CPU.Option B (alternative, no admission change): memoize the locked-manifest parse per process. Key it on the bytes of each locked package's
apm.ymlread in_collect_locked_dependencies, returning a freshAPMPackageper call. Admission still runs on every pass.integration/mcp_config_view.py, plus possibly theAPMPackage.from_apm_ymlcache owner.from_mappingper call may remain.Recommendation. Option A is at the ~3% kill line and carries the higher trust risk. I recommend killing A on this note. Option B, if pursued, should be a separate small lever with its own row and a W3b pre-read, since it touches what the MCP view reads.
danielmeppiel commentedon Nov 25, 2026
Lever 4 Option A (one admitted MCP view shared by the commit gate and the MCP phase) is killed by the PERF VP ruling (17:25 CET): it changes full-pipeline trust admission for about 3% CPU. Option B (a per-process, byte-keyed memo of the locked package apm.yml parse, returning a fresh object, with admission unchanged) is approved as lever 4b, with its own stacked PR, row, S93 and W3b review.
fix(install): a memoized manifest parse error names the manifest, as …
danielmeppiel commentedon Nov 25, 2026
Lever 4b (#5501, a byte-keyed manifest parse memo) is killed by the regent ruling: at c5e21db only 1 cell met the bar (CPU >= 1.03x with paired outside +/-2%). L5 and L6 are restacked on #5499.
perf: apm_cli.integration exports resolve on first use (#5491)
danielmeppiel commentedon Nov 25, 2026
L5 (lazy
apm_cli.integrationexports, PEP 562) is killed. Row 45661949383 (15 pairs, output "same"):install-warmregresses to 0.97x CPU at t10 (1.372 -> 1.418) and t50 (4.478 -> 4.612, paired 1.026), against no-op gains of 1.00x-1.03x. The bar for pure-redundancy levers allows no regressing cell. On the attested hits it dropped 34 modules, but a journey that loads every integrator anyway cannot gain from laziness: the 11-25 lesson held again. Branchdanielmeppiel-perf-5491-lazy-integrationis deleted (no PR was opened).danielmeppiel commentedon Nov 25, 2026
#5491 closing note
Verdicts. All rows are 15-pair CI benches (3 runners x 5 pairs), RTT 30 ms, with output "same" in every cell. Each number is CPU p50 speedup, with paired wall new/base in parentheses.
apm_cli.integrationexportsinstall-warm0.97x at t10 and t50. 45661949383S93 input-mutation oracle: 0 findings at every shipped head, in attested and attested-frozen modes on tree-10-mcp and tree-10-claude-routed.
Stack row: main f68cebd -> #5499 top 17eca68 (#5423 + #5493 + #5496 + #5499):
The Linux tree-10 frozen no-op CPU p50 is 0.909 s, under #4770's <= 1 s bar. On Windows, t10 is 1.23 s.
What remains. The rest of the frozen hit is dominated by imports of modules it actually executes (the 11-25 lesson; L5 confirmed it on warm). No further lever is open under this issue. #5493 -> #5496 -> #5499 land as a stack after #5423.
perf(install): the attested --frozen hit judges the frozen preflight …
perf(install): fold W3d N1/N2 on the frozen preflight tape (#5491)
fix(install): the preflight tape is matched by exact type; full runs …
perf: the running CLI's package version is looked up once per process (…
perf(install): the fast path checks the Codex ownership ledger withou…
Merge pull request #5496 from microsoft/danielmeppiel-perf-5491-versi…
chore: spec waiver for #5491 (no observable behaviour change)
chore: spec waiver for #5491 (no observable behaviour change)
Merge pull request #5493 from microsoft/danielmeppiel-perf-5491-prefl…
Merge pull request #5499 from microsoft/danielmeppiel-perf-5491-codex…