Repository navigation
perf(gateway): avoid repeated GitHub reader identity work - #185685
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Select current GitHub identity facts without deriving unused credential paths, and remove the duplicate synchronous client-policy projection from publication-options reads. Keep credential rotation, caller revocation, and all returned reader guards live. Add work-count regressions and synthetic owner measurements.
cfd8f85 to
e3f9c00
Compare
…85685) * perf(gateway): avoid repeated GitHub reader identity work Select current GitHub identity facts without deriving unused credential paths, and remove the duplicate synchronous client-policy projection from publication-options reads. Keep credential rotation, caller revocation, and all returned reader guards live. Add work-count regressions and synthetic owner measurements. * fix(perf): type GitHub preview benchmark instrumentation
What Problem This Solves
Frequent GitHub preview and publication-options reads repeat identity-selection work even when their cached content is unchanged.
User Impact
Reduces CPU and allocation during GitHub reads without changing response bytes, credential rotation checks, caller revocation, or session visibility.
Why This Change Was Made
Identity selection no longer constructs credential directories that its callers discard. Credential and child-environment consumers resolve their own selected profile path; token rereads remain live. Durable publication-options readers validate and project the current client once per synchronous read instead of twice. Every returned reader retains a live authority check; incognito retains its existing internal guard. No cache, TTL, schema, or public contract changes.
Evidence
Acceptance: identical synthetic preview bytes and upstream/auth counts, fewer unused path/role operations, lower allocation/CPU per owner operation. Base and candidate run in AB/BA order; CPU timing and allocation passes are separate for preview/options. The preview fixture has 10,000 session references, 100 issue/PR links, eight repositories and 40 agents, with a mocked GitHub API and isolated synthetic credentials. It is owner-boundary proof, not a Gateway load test.
Options: two counterbalanced pairs, 5,000 reads per arm/pass/pair (10,000 per revision in each separate timing/allocation pass). Uses the existing authorization fixture with plain role counters and mocked storage/role-policy lookup; it measures the prepared reader, not full RPC or real database latency. Responses matched in every arm.
Selection: two counterbalanced pairs, five samples × 5,000 calls per arm per pair (50,000 calls per revision). Preview: 3,000 calls per arm, two counterbalanced timing pairs plus one declared extra pair for mixed CPU signs (9,000 calls per revision), and two separate counterbalanced allocation pairs (6,000 per revision). CPU pair deltas were +3.1%, −17.3%, −2.9%; report the modest signed-mean improvement, not the noisier wall-time spread. Preview allocation fell in both pairs. Timing-arm 1-minute host loads (base/candidate) were 45.1/42.4, 42.2/43.3 and 58.0/53.0; the third pair had higher wall time on both sides. Every warm preview retained one live credential revalidation and made zero upstream fetches/JSON parses; serialized response digests matched.
Reproduce with
scripts/perf/github-tool-selection-measure.tsandscripts/perf/github-preview-authority-measure.ts; each header documents the optional adjacent frozen owner module for baseline comparisons. The options owner measurement is opt-in in its existing regression test.The identity regression fails on the base with ten unused state-directory reads for ten assertions (32 other tests pass). The options regression fails on the base with two live role-policy evaluations instead of one (eight other tests pass); it also verifies revocation at all returned reader boundaries. That red wrapper subsequently detected a concurrent edit to the separate identity owner; the options baseline blob remained unchanged. Final options proof completed with wrapper exit 0. An earlier identity green attempt stopped before tests because the source-snapshot verifier observed the options edit; final sources were frozen before the replacement run.
Runtime production delta: +9 lines (+8 identity owner, +1 options owner). The non-test diff is +243 lines including 234 lines of benchmark/inventory tooling; tests add 111 lines, mostly the opt-in options measurement. The small growth separates profile-path preparation from selection without duplicating the selection policy, and explicitly guards the raw session reader after removing the inner duplicate check. Core typecheck, targeted type-aware lint, formatting, export-collision guard, and the nine options tests passed. The session-target file passed 36/37 cases; its first linked-worktree discovery case hit the existing five-second handler deadline during the cold run. That failure is recorded, not masked; the unchanged case also timed out in its targeted candidate replay. The same case passed with the original production owners at base
fcfa2def7a0d. This is an unresolved, timing-sensitive local comparison, not a proven inherited failure and not a claimed fix. The five-second production deadline and test assertions were unchanged. All 56 tests across read identity, tool identity and App installation consumers passed, including the new regression. The two script-closure files passed 32 tests. Independent subagent review (autoreview route unavailable): static review through P2, scoped-clean. The final one-line CLI-entry inventory addition was also reviewed clean. The direct review route was refused because it did not match the operator configuration; no configuration was changed.Scope/gaps: synthetic owner measurements only. The requested fast-path rule applies to these redundant-work deletions; no live Team load or multi-pair Gateway stress campaign was run. Full handler/storage/network latency is not inferred from these numbers. Testbox was not allocated; PR CI supplies broad proof.
CI follow-up: the first run completed 42 jobs successfully and failed only the benchmark scripts typecheck (plus the aggregate gate): an untyped identity array and an overloaded
JSON.parsewrapper. The follow-up types the array from the preparation API and preserves parser overloads through a forwarding Proxy. The scripts type lane, targeted lint and benchmark smoke passed locally; independent review of that repair was scoped-clean through P2. No production code or measured warm-path behavior changed.Final hosted validation: CI run 40476639241 completed successfully on
e3f9c0037a85fa315fcd3a233017029efbc5db73(44 successful jobs, 27 intentionally skipped). Security review also completed successfully with its review job targeting that exact PR head and CI run. The local discovery-timeout comparison above remains an explicit limitation; green selected CI is not presented as a diagnosis of that timeout.