Repository navigation
perf: reuse compiled matchers for support redaction - #170225
Conversation
Account for CPU work in async preparation continuations, split tool construction into event-loop slices, and reuse canonical diagnostic redaction matchers. Preserve FIFO admission, live tool authority, masking semantics, and SQL behavior.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
|
Codex review: needs changes before merge. What this changesThis PR reuses canonical compiled vendor-token matchers in support redaction while preserving support-specific masks. Example: Redacting the support string "vendor ghp_abcdefghij".
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep this maintainer-authored PR open: the focused matcher cutover is useful and has no actionable findings; the author's validation hold remains active. Priority: P2 Before merge
FindingsNone. Agent review detailsHow this fits togetherSupport redaction sanitizes strings and snapshots used by diagnostic exports and trajectory metadata, returning masked text before those consumers record or export it. flowchart TD
A[Trajectory metadata] --> C[Support redaction]
B[Diagnostic export] --> C
C --> D[Canonical compiled matchers]
D --> E[Vendor admission filters]
C --> F[Support specific masks]
E --> G[Sanitized output]
F --> G
Technical reviewBest possible solution: Retain this narrow reuse of the canonical matcher owner while preserving the existing support masking contract. Do we have a high-confidence way to reproduce the issue? Source confirms support redaction bypasses canonical matcher optimizations on main; supplied Gateway profiles place redaction within preparation stalls, but do not establish a causal latency improvement for this patch. Is this the best way to solve the issue? Reusing the existing compiler removes duplicate matcher construction without introducing another owner, changing configuration, or altering support-specific AWS masking. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 76edfee2d220. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +1, Tests +19. Total +20 across 3 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (8 earlier review cycles)
Reviewed October 12, 2026, 10:55 PM ET / October 13, 2026, 02:55 UTC (Revision 9). |
Preserve the prepared profile facts alongside event-loop yields. Extract final hook wrapping without changing its ordering or caller context to keep tool assembly within the source-size limit.
Three alternating comparisons showed worse warmed latency in two candidate runs. Retain only the separately reviewed support-redaction matcher optimization and its compatibility fixtures for a focused performance comparison.
Reuse canonical vendor-token matchers, including their prefix filters and linear scans, for synchronous support redaction. Preserve support-specific full AWS masking and existing redaction output. Add compatibility fixtures and load the real redaction dependency closure in the isolated updater test fixture. This addresses one profiled contributor to Gateway stalls. Quiet-host latency improvement is unmeasured; SQL and authority behavior are unchanged.
What Problem This Solves
Support redaction runs synchronously while the Gateway prepares trajectory metadata. It compiled a separate array of vendor-token regexes at module load, bypassing the canonical compiler's prefix filters and linear matchers. CPU profiles place this scanning path inside warmed main-thread stall windows.
User Impact
Reuse the canonical compiled vendor matchers and delete the duplicate compilation path. Benign metadata can skip unnecessary regex scans. Preserve support-specific full AWS masking, Unicode boundaries, data-URL exemptions, and all other masking output. Five compatibility fixtures cover the cutover. The updater's isolated test loader loads the real redaction dependency closure.
This is a small, behavior-preserving optimization of one contributor to stalls. It does not resolve the larger tool/schema preparation cost. There are no configuration, schema, SDK, update, or service-lifecycle behavior changes. No authority/integrity check or SQL operation is removed. Removed checks and accepted edge cases: none. The diff is three files, +25/-5 lines (production +6/-5).
Evidence
Where the stalls occur
An earlier diagnostic CPU profile of synchronized source
ddaf75ff383b0bef772a5eb8c37a75b80869ec88ran on a remote Linux Testbox with four visible AMD EPYC CPUs and Node 24.19.0. CPU idle was 99.75% before and 99.88% after the workload. It captured all 72 timer windows >=8 ms across ten warmed turns. Nineteen windows were dominated by tool/schema/catalog work; 47 were mixed. The largest window was 34.417 ms, with 34.095 ms assigned to GC samples; the allocating owner remains unresolved.These are exclusive, rule-based sample-interval groupings, not causal CPU-time totals. Sparse intervals over 2 ms remain unattributed. The profile includes instrumentation overhead and is separate from the final comparison below.
Patch comparison timing observations
Three unprofiled alternating pairs, M,C,M,C,M,C, compare baseline
3c79d119f2945474a483073eaa827c9801eb0c42with candidate6d3ca762b292140ea30b0be227c42cf37ba50e2b, ten warmed turns per run. Source manifests and collector bytes were verified; all six runs have complete warmed coverage and no dropped windows.Quiet-host latency is unmeasured for this patch. The final remote request queued and was canceled under the immediate-capacity policy. These local controls ran on a 32-core Mac, Node 26.11.1, with sampled one-minute load 55.79-114.26. They are observations only: neither a latency improvement nor a regression can be inferred. The p99 <=8 ms / max <=15 ms targets are not demonstrated.
Event-loop p50/p99 rows aggregate each run's median per-turn percentile. Worst observed delay: 919.60 -> 680.00 ms. Pooled 30-turn p50/p95: 1914.28/8700.19 -> 1403.61/2525.92 ms (nearest-rank p95). Pair directions vary, the median run p95 is higher for the candidate, and one baseline turn took 15.74 seconds; the pooled result is not a causal performance claim.
SQL and requests
One complete alternating SQL pair on the same compared source pins, ten warmed turns per revision, using a task copy of the shared harness with unchanged counting/attribution helpers. The first candidate attempt and the next baseline attempt both hit the existing 15-second WebSocket handshake deadline before any measured turn. Both incomplete attempts are excluded. The current one-live-pair testing allowance is used; this is not three-pair SQL evidence, and repeatability is unmeasured. The three timing pairs above are complete.
These are single run-level observations, so median [min-max] equals each displayed value [value-value]. Raw windows include background work; whole totals include startup, other flows, and shutdown. All 3,638 causal warmed statements link to actual request records. Of 109 normalized warmed SQL shapes, 25 have different counts.
The +18 causal statements across ten turns comprise one 13-statement temporary-trigger setup in session-lifecycle projection, four transcript-worker statements, one auth-profile read, one entry-admission statement, and one fewer actor-durable statement. Trigger setup is cached by database handle/schema version. Whole-workload setup counts were 65 -> 104, so this is genuinely additional setup in the observed run, not solely a shift from startup into a warmed window. No added SQL/request path exists in this patch; it changes only synchronous string matching. The setup/read-count variation is outside that owner, and this single pair does not establish patch causation.
Families classify normalized SQL shapes; selected-row helper shapes use execution-site mapping. Request IDs are unioned within each family; families may overlap. The raw-window +209 statements split into +18 turn-caused and +191 background statements. By execution site, memory-core accounts for +128, trigger setup +26, and other sites +55. SQL run-boundary load was 82.85-90.79 for baseline and 90.40-196.96 for candidate on 32 CPUs. No SQL saving or whole-Gateway performance improvement is claimed.
Validation
Pre-integration CI run 38322403843 passed: 36 successful jobs, 26 intentionally skipped, and the required CI gate green. That CI merge combines measured candidate
6d3ca762with main5cf2615e65ec2e8344c836a5572c523783981e60. Build, Critical Quality, and all seven selected Security High CodeQL shards also passed.Touched production-area T1 is 0 -> 0: the changed redaction module contains none of the native inventory's five SQLite primitives in either revision, so the inventory excludes it before call classification. The whole-tree ratchet result above comes from CI.
A supplemental local static pass did not complete successfully: its three concurrent Knip scans reached the existing 600-second limit before returning findings. Redundant local Madge, export-collision, and worker-ratchet work was then canceled and replaced by the already-passing exact-head CI evidence. These cancellations and the timeout are not counted as passes.
An additional synthetic check confirmed identical redaction output for 14 short inputs across six counterbalanced batches. Its elapsed timings varied widely on the loaded host and supply no performance claim; it is not a Gateway responsiveness benchmark.
Follow-up
The larger measured contributor is tool/schema/catalog preparation. A follow-up should let the existing tool-finalization owner publish one immutable provider-specific descriptor snapshot, with projection and fingerprint computed once, while keeping executors, abort state, and current authority per attempt. That work is outside this small matcher cutover.
Supplemental Static Gate
The sequential local Knip retry was canceled before starting after roughly 30 minutes without a CPU slot. The supported exact-head main-tier CI fallback completed all three export scans. The script scan passed with zero entries; production and full-tree scans reported only obsolete Control UI exports. The dependency/unused-file checks also reported an obsolete UI select shim. No changed file has a finding.
This Knip result is inherited, not green. Every reported finding exactly matches scheduled main run 38322669274, including the same symbols, files, and scan categories. Main subsequently removed those exports and the shim in
61edf206c15d201e857e6bf8419b30ff4dd1673f. GitHub's stored PR merge ref still used the older CI base, so the branch was updated with main to incorporate the repair. The remaining jobs in that old-head fallback were canceled after saving the completed dependency result. The timeout, inherited failure, and canceled jobs are not counted as passes.The redaction reentrancy test passed 11/11 on the exact head. No timeout or canceled check is counted as a pass. The recorded source pins and measurement limitations above are unchanged.
Landing Head and Validation
Landing head
ba1167ad2ebe10c6e68c9ed7b6a32e15c5825eb6merges mainf9af58c66f79f23a2e051cfe5b9feccf6befc2dawithout conflicts. All three changed files are byte-identical to the reviewed/measured candidate6d3ca762; the diff against integrated main is still +25/-5 lines. Existing focused behavior proof and reviews are reused for that unchanged patch. Measurements above remain evidence for their recorded source pins, not a new measurement of the integrated main base.Fresh PR CI 38340082322 passed on this head: 35 successful jobs, 26 intentionally skipped, and the required CI gate green. Its types, lint, formatting, source contracts, export-name collision checks, Madge, selected tests, and ratchets passed. Whole-tree T1 is 455 -> 455, compatibility-only 9 -> 9; touched-area T1 stays 0 -> 0. All changed-file dialect categories stay 0 -> 0.
The new-head dependency shard completed every Knip export scan. Script exports and full-tree unused files passed with zero entries. Production/full-tree export scans and the production unused-file check failed on existing writer-admission, skills, and dropdown exports/types, plus the unused writer-admission service. All 18 emitted finding lines exactly match latest scheduled main, in the same scan categories. None is in a changed file. This is proven inherited static failure, not a passing Knip result; the campaign's inherited exception applies and the findings are recorded for the main-repair owner.
Remaining supplemental-run jobs were canceled after the dependency result was captured. That supplemental run is not claimed green. The required PR CI above completed successfully. The unchanged patch retains its two clean reviews and focused behavior evidence; no new performance claim is made for the integrated base.