Repository navigation
fix(codex): stop the managed config mirror from reordering the file on every pass - #44467
Conversation
…n every pass When the managed Codex home's daemon socket path is too long (typical on macOS), Orca adds a [features] daemon_auto_start guard to the managed config.toml. The mirror re-added that table at the very end on every pass, while project trust grants and hook approvals append their tables after it, so each launch-preparation pass after a change moved blocks around and republished the 330 KB config. A pass that writes is never cached, so the next launch ran the whole hook preparation again. The guard is now applied to the settings part before the managed home's own tables are joined on, so it keeps one position and appended tables stay where they are: a pass after a trust grant now writes nothing and the next launch reuses it. Existing configs settle with one rewrite.
… the same way, measuring the socket path once
…ocks that named it
Perf scan 3: PR #44467 at 9000f7cI compared FindingsNone. No P0 or P1. What changed since scan 2 (a78ff44, PASS)
None of it is repeated here. Is the new baseline number right?
Regression classes touchedThe dispositions are the same as scan 2, since no runtime code changed:
Six questionsThese carry over from scan 2 unchanged; the code they graded is byte-identical at this head:
Evidence
ResidualThese carry over from scan 2:
|
|
Status: ready Problem: with a ~330 KB Codex config (~1,900 worktrees), after every project-trust grant or hook approval the hook-preparation pass on the main thread rewrote the managed User-facing change: Codex launches after a trust grant no longer rewrite the managed config, and the launch after them reuses the cached pass. Launch bursts on long-path homes use about 33% less main-thread CPU. Config contents are unchanged, except that the guard's Fixed during review:
Deferred: short-path homes (usual on Windows) don't get the guard, so their pass is unchanged. Moving the pass off the main thread is the follow-up PR. Verified:
Benchmark: head=a78ff44e1a9eb59dcc4914d278c4ff9c99f40cc2 gate=PASS host=omarchy (Linux QA machine) corpus=332 KB config, 5 grant launches then 1 unchanged launch, 2 runs per arm, base=8bc232f5ed8 files=src/main/codex/configuration/settings/codex-config-mirror.ts,src/main/codex/configuration/settings/codex-config-mirror-source.ts,src/main/codex/configuration/settings/codex-config-runtime-owned-values.ts,src/main/codex/configuration/shared-server/codex-daemon-socket-path-guard.ts listeners=none (direct installForLaunchPrep) | guard on: burst 1834/1887 → 1229/1255 ms, rewrites 5 → 0, next launch full pass 377/389 ms → cached 1.3/1.4 ms | guard off: 1026/1181 → 1077/1121 ms, unchanged. Only commit after a78ff44 is 9000f7c (baseline file only). |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Benchmark rerun on the exact final head, which only changed a baseline file after the earlier run. Same harness: a 332 KB config, a burst of 5 grant launches, then 1 unchanged launch; 2 runs per arm, on a Linux QA machine under shared load. The direct
The machine was busier than in the first run, so absolute times are higher for both arms. The relative result is unchanged. Benchmark: head=9000f7ccad1bfc107b5b3a7e95a40e0042c8eda6 gate=PASS host=omarchy corpus=332 KB config, 5 grant launches then 1 unchanged launch, 2 runs per arm, base=9c28817280b6 files=src/main/codex/configuration/settings/codex-config-mirror.ts,src/main/codex/configuration/settings/codex-config-mirror-source.ts,src/main/codex/configuration/settings/codex-config-runtime-owned-values.ts,src/main/codex/configuration/shared-server/codex-daemon-socket-path-guard.ts listeners=none (direct installForLaunchPrep) | guard on: burst 3159/3628 → 1775/1593 ms, rewrites 5 → 0, next launch full pass 664/598 ms → cached 2.8/2.2 ms | guard off: 1602/2599 → 1310/1473 ms |
Problem
Every Codex launch runs a hook-preparation pass on the Electron main thread: approvals, settings mirror, hook trust, status. With a 330 KB managed
config.toml(~1,900 worktrees), that pass costs a few hundred ms of CPU. A reuse cache is supposed to skip it when nothing changed, but it only stores a pass that wrote nothing.When the managed home's daemon socket path is too long for
sun_path, the mirror adds a[features] daemon_auto_start = falseguard. That's true for typical macOS user-data paths and long Linux paths. The mirror re-added the guard at the end of the file on every pass. Project trust grants and hook approvals append their tables after it. So after any grant or approval:The legacy shared-home refresh had the same ordering. Separately,
stripCodexDaemonOverridecopied every line kept so far at each table header, which is quadratic in the number of tables. The bug is in stable (v1.4.263).Fix
features = {…}is still recognized and doesn't get a second[features]table.~/.codex, because promotion strips it.Short managed-home paths, which is the usual Windows case, never get the guard, so this PR doesn't change their pass. Moving the pass's CPU off the main thread is the follow-up.
Measurements
Linux QA machine, PR head
a78ff44against main8bc232f, two runs each. The setup is a 332 KB system config and the realinstallForLaunchPrep; the burst is 5 launches, each after a project-trust grant to both configs; the next launch has no change.Test
codex-config-mirror-daemon-guard.test.tsuses the real guard with a long home path.[features]table, CRLF, each with a mirrored user hook approval.featurestable stays a single valid definition.Each case fails without its fix, except the own-
[features]control. Tests that switch the guard off now mock the socket-path measurement.