Repository navigation
perf(boards): avoid copying freshly decoded dashboard layouts - #184391
Conversation
|
🦞👀 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 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. |
Reuse the owned layout normalizer after SQLite row decoding. Keep the HTML metadata declaration copy so snapshot mutations cannot affect view metadata, and retain full copies for caller-owned public operations. Removes a full-layout clone from every board snapshot read; preserves payloads, authorization and FIFO admission.
|
Codex review: needs changes before merge. What this changesThis PR normalizes freshly decoded dashboard layouts without cloning them and preserves isolation between snapshots and HTML view metadata. Example: Read a dashboard containing 24 plugin widgets with nested props.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep open: this is a useful, focused allocation reduction, but the added clone-spy filter needs an object-type check before it can typecheck. Priority: P2 Before merge
Findings
Agent review detailsHow this fits togetherThe Board SQLite kernel decodes persisted tabs and widgets into snapshots consumed by dashboard RPCs and mutation operations. flowchart LR
A[Dashboard client] --> B[Board RPC]
B --> C[Board storage worker]
C --> D[SQLite row decoder]
D --> E[Owned layout normalizer]
E --> F[Snapshot and isolated metadata]
F --> B
Technical reviewBest possible solution: Keep the production optimization and narrow the spy argument to a non-null object before checking for widgets. Do we have a high-confidence way to reproduce the issue? Current-main source shows the redundant full-layout clone, and the added filter's type error follows from the inspected generic clone and spy contracts; no target code was executed. Is this the best way to solve the issue? Reusing the existing owned normalizer is the smallest complete production change because decoded objects are fresh and the separately copied declarations preserve the remaining sharing boundary. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 977d7287c010. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
PR surfaceSource +3, Tests +18. Total +21 across 4 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 Reviewed October 26, 2026, 4:40 AM ET / 08:40 UTC. |
485d74d to
05f8f3c
Compare
…aw#184391) * perf(boards): normalize freshly decoded snapshots without copying Reuse the owned layout normalizer after SQLite row decoding. Keep the HTML metadata declaration copy so snapshot mutations cannot affect view metadata, and retain full copies for caller-owned public operations. Removes a full-layout clone from every board snapshot read; preserves payloads, authorization and FIFO admission. * test(boards): narrow clone inputs before layout inspection
What Problem This Solves
Reading a populated session dashboard deep-clones the entire freshly decoded layout, including every plugin widget's props, before returning the snapshot.
User Impact
Dashboard snapshots require less CPU and allocation with identical payloads. This is a bounded improvement to populated board reads; it does not eliminate broader host or database-admission stalls affecting empty boards. No schema, configuration, authorization, or ordering changes.
Why This Change Was Made
The SQLite decoder already owns fresh tabs, widgets, and parsed props. Reuse the existing owned-layout normalizer there, while public operations continue copying caller-owned layouts. Copy only HTML declarations into view metadata to preserve isolation from the mutable snapshot. Production delta: +3 lines (one isolation comment/copy and formatting); no cache, second normalization algorithm, or new invalidation lifecycle.
Evidence
On current-main baseline d46ce5c, the strengthened existing store test fails specifically because it observes one full-layout copy. The candidate passes and also proves declaration isolation, subsequent-read isolation, and omission of HTML BLOBs.
Owner microbenchmark: 10,800 synthetic sessions, 24 native widgets with 120 structured data points each, 3,000 warmed reads per case. Timing and sampled-allocation passes are separate; payload hashes match.
CPU fell 63.1% and sampled allocation 55.4% for this populated fixture. Empty reads remain about 0.04 ms p50 and 22 KiB/read. Host load was approximately 57–60 during the owner measurements; these are owner costs, not whole-Gateway CPU savings.
Real dist-Gateway phase proof uses isolated synthetic state, 10,800 sessions, 40 enabled bundled plugins, 65 authenticated WebSocket clients, and concurrent board/list requests. Baseline has 1,820 board calls: routing p50/p95 0.054/0.186 ms; reader retention 0.094/0.317 ms; read admission 106.634/231.013 ms; worker round trip 3.246/7.421 ms. No task, PR, GitHub, or Workboard service lookup occurs in board.get. Candidate has the same 1,820 board calls and matching wire-payload hash. Candidate phase p50/p95: routing 0.049/0.171 ms; reader retention 0.086/0.246 ms; admission 74.538/145.494 ms; worker round trip 1.977/4.034 ms. Server store-total p50/p95/p99: 109.672/236.934/322.603 → 76.540/148.622/184.344 ms (1,820 samples/arm). Client populated-board p50/p95: 136.581/313.829 → 102.000/198.307 ms (896 samples/arm); client list p50/p95: 23.604/53.259 → 21.572/47.784 ms (260 samples/arm). The untraced, instrumented burst completed in 7.80 → 5.18 s. Host one-minute load varied 55.1–58.4 on baseline and 50.2–54.9 on candidate; this short serial comparison supports phase attribution, not a production-wide tail claim or an adverse decision. Per-method client p99 has fewer than 1,000 samples and is not used as a gate.
The lane's explicit fast-path protocol applies: deletion of redundant recomputation with unchanged authority/FIFO, owner CPU+allocation measurement, targeted Gateway attribution, focused tests, CI, and independent review. No ten-minute AB/BA or A/A campaign and no live production load were run; whole-Gateway CPU/GC/allocation/loop effects are not claimed.
Validation: formatting and changed-file lint passed; 41 focused tests passed (board-store, board-layout, sqlite-board-codec; wrapper wall time 128.66 s including artifact preparation, board-store test body 26.9 s); export-name guard passed; 26 closure tests passed (69.91 s wall). The first CI run passed 54 checks but caught TS2638 in the clone-observation predicate; the test now narrows unknown values to non-null objects before using
in. The failingtsconfig.core.test.other.jsonleaf, changed-file lint, and the targeted regression all pass locally (regression wrapper wall time 118.48 s including artifact preparation); fresh review found no issues. Corrected-head CI run 40294057978 is green; all 57 reported checks passed. The six changed-node test execution steps took 221/135/61/119/68/48 seconds (652 CI seconds total, including the dependency closure rather than only this regression). Initial test replay was invalidated by concurrent formatting and was rerun against frozen sources. Independent subagent review (autoreview route unavailable: configured provider mismatch) found no actionable P0–P2 findings. No Testbox lease was used, per lane instructions.