Skip to content

perf(install): attested --frozen no-op fixed cost after #5423 (Linux t10 CPU 0.97 s, Windows 1.41 s) #5491

Done

Description

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:

install-frozen-noop tree-10 CPU p50 (base -> new) paired wall
Linux 45626815760 1.142 -> 0.970 s 0.895
Windows 45626830274 1.797 -> 1.406 s 0.789

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)

  1. Run the frozen preflight once per run and reuse its result for the parity render, keeping AF4's print point.
  2. Parse the lockfile once per run on the fast path.
  3. Defer the codex_plugins / bundle imports out of _refuse_native_* when no native plugin is locked.
  4. On Windows, the ~1.4 s t10 fixed cost needs its own profile (PROFILE=1 is not supported on Windows runners today).

Activity

  1. added
    performance
    type/performance
    status/needs-triage
    on Nov 25, 2026
  2. danielmeppiel commented on Nov 25, 2026

    @danielmeppiel
    CollaboratorAuthor

    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".

  3. danielmeppiel commented on Nov 25, 2026

    @danielmeppiel
    CollaboratorAuthor

    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:

    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.

  4. danielmeppiel commented on Nov 25, 2026

    @danielmeppiel
    CollaboratorAuthor

    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.

  5. danielmeppiel commented on Nov 25, 2026

    @danielmeppiel
    CollaboratorAuthor

    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.

  6. danielmeppiel commented on Nov 25, 2026

    @danielmeppiel
    CollaboratorAuthor

    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).

  7. danielmeppiel commented on Nov 25, 2026

    @danielmeppiel
    CollaboratorAuthor

    #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.

    Lever PR / head Verdict Row (vs the lever below it)
    1. Frozen preflight judged once #5493 @ 4a1638c Ship Linux frozen t50 1.07x (0.923); Windows frozen t10 1.11x (0.935), t50 1.13x (0.888). 45639466366, 45639482088
    2. CLI version lookup once per process (not the 13 lockfile reads; see the correction above) #5496 @ f629370 Ship 1.00x-1.04x in all 8 cells. 45639586174, 45639602441
    3. Codex ledger path without the registrar import chain #5499 @ 17eca68 Ship 1.01x-1.05x in all 8 cells, plain no-op included. 45652856249, 45652876729
    4A. One admitted MCP view for the commit gate and the MCP phase none Killed on the scope note Full-pipeline trust-admission change (TOCTOU) for about 3%
    4B. Byte-keyed manifest parse memo #5501 (closed) Killed Only 1 cell met the trust-adjacent bar (>= 1.03x in 2+ cells, paired outside +/-2%)
    5. Lazy apm_cli.integration exports none Killed install-warm 0.97x at t10 and t50. 45661949383
    6. Receipt validation memo none Killed 0 cells at >= 1.03x; Windows frozen 0.99x. 45666839467, 45666852876

    S93 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):

    frozen t10 frozen t50 plain t10 plain t50
    Linux 45664759068 1.158 -> 0.909 s, 1.27x (0.784) 2.684 -> 1.829 s, 1.47x (0.689) 0.887 -> 0.859 s, 1.03x (0.959) 1.623 -> 1.615 s, 1.01x (0.988)
    Windows 45664773913 1.766 -> 1.234 s, 1.43x (0.711) 4.656 -> 2.656 s, 1.75x (0.571) 1.203 -> 1.156 s, 1.04x (0.962) 2.297 -> 2.250 s, 1.02x (0.994)

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancestatus/needs-triagetype/performance

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions