Repository navigation
perf: reduce model picker work while searching - #189949
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. |
|
Codex review: needs maintainer review before merge. What this changesThis PR selects mounted model choices using the existing catalog index instead of repeatedly scanning large provider lists. Example: Open and search a 1,000-model catalog on the supplied mobile Chromium 6× fixture.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR makes a focused, measured performance improvement, and review found no actionable code or security defect. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Control UI model picker combines catalog choices and search state with virtualizer membership to render visible rows and pinned keyboard choices. flowchart LR
Catalog[Model catalog] --> Prepared[Prepared groups and index]
Search[Search and disclosure] --> Layout[Ordered visible row keys]
Prepared --> Layout
Layout --> Window[Existing virtualizer]
Window --> Mounted[Mounted model selection]
Prepared --> Mounted
Mounted --> UI[Picker rows]
Technical reviewBest possible solution: Retain this focused optimization using the prepared catalog index and existing virtualizer while preserving selection, ordering, and row identity. Do we have a high-confidence way to reproduce the issue? Current-main source scans each complete provider list for mounted membership, and the supplied exact-revision measurements exercise that cost through the production picker; no target code was run during review. Is this the best way to solve the issue? The change removes unnecessary membership work using existing indexes, preserves contiguous-list order, and filters geometry-only invalidations without adding another state owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 418bb925ca47. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +23, Tests +8. Total +31 across 3 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 31, 2026, 10:03 PM ET / November 1, 2026, 02:03 UTC. |
|
Merged via squash.
|
What Problem This Solves
Opening and searching a large model catalog repeatedly scans every model to select its few mounted rows. Reuse the prepared catalog index and virtualizer keys for large contiguous lead/More lists; small lists keep their existing filter. An equality-bearing keys memo prevents geometry-only updates from repeating selection. The 1,000-model mobile fixture keeps the same catalog order, keyed focus, shortcuts and visible choices. No domain owner, native row-measurement policy, lazy boundary, dependency or new cache changes.
Source-mapped counts: membership checks fall 5,973→54 first-open/search and 4,964→36 warm. Added mounted-key lookups are 81/60 and key-projection items 302/261. Row creation, uncached geometry reads and size corrections remain 45/34; window publications remain 65/51. Small-list helper calls rise 9→16 / 6→10; timings include that cost.
Evidence
Times are milliseconds, median / nearest-rank p95. Each triplet is counterbalanced base/head/base on one host; all observations and A/A controls are retained. Chromium is mobile 390×844/touch with 128 MiB V8 old-space, thread-CPU task metrics and whole-renderer CPU. This is not physical Android OS memory-pressure proof. WebKit reports application/wall elapsed time, never CPU.
The refreshed 6× source cohort is
ebf13610e1b8b29462c68eb71e18450effe6fdc7→536f23ac8b4f628fa688734da4ce559dbcc98a01: 180/180 observations pass. The fresh 1×/4×/WebKit cohort is72cab24990b3746574ac83e3d73c79530b8cc198→c97c988aa23605a902d7f003a57fee39d84f3c38: 360/360 pass. The transition between these cohorts includes broader main changes; the measured picker UI and action sources are unchanged. The cohorts retain separate source pins. The final merge includes the landed drawer/image/Systems work and #190033; timings retain their exact source identities rather than being relabelled as final-head timings. The range patch and its three files are byte-identical throughout.First-open/search clears the ≥5% 6× task threshold (−5.71%) with script −14.63% and renderer CPU median −4.56%. Warm's refreshed 6× gain is 3.84%, not separately claimed as ≥5%. First-open ready time improves 290.55/350.3→284.75/342.5 ms in the pooled 6× cohort. The 300 ms target remains unmet; no unavoidable floor is claimed.
Accepted tradeoffs and measurement limits
This is an aggregate flow win, not an all-metrics improvement. In the refreshed 6× cohort, first-open renderer CPU p95 +0.46% and wall p95 +0.47% are below the campaign's 1% noise threshold; the initial CPU-tail concern (+15.06%) was tested with 20 additional triplets rather than omitted. Layout median/p95 +3.13%/+4.83% and style median +3.16% remain disclosed (style p95 −6.17%).
At fresh 1×, all task/CPU/wall medians and p95s improve. First-ready median rises 70.2→74.4 ms (+5.98%) while its control is 75.2 ms; p95 rises 0.1 ms, and paired median is −0.69%. Warm style/layout p95 rises 0.281/0.273 ms. Warm heap-after p95 rises 1,263,908 B (+3.88%).
At fresh 4×, task/CPU/wall and first-ready medians/p95s improve. First layout p95 rises 3.128 ms (+6.55%; paired p95 +15.96%, A/A +12.33%). Warm net-heap delta median rises 998,236 B (+106.74%); this remains an adverse raw result. The observations have low/negative and ~1.9 MB net-change clusters (10/20 low or negative controls versus 5/20 candidate), so signed paired percentages cannot establish allocation savings. No GC trace proves its cause. Warm heap-after median/p95 changes +1.69%/−0.49%; RSS −0.17%/+0.28%. These bounded endpoint costs are accepted with the measured aggregate win; no all-memory-green or leak-free claim.
At WebKit, application p95 rises 1 ms in each flow (+0.63%/+0.88%); first wall p95 rises 0.35 ms (+0.15%), all below the sub-1% band. First assertion-tail median/p95 rises 7/10→8.5/11 ms (+21.43%/+10%). Its boundary is the last MutationObserver/native-value commit to scenario end, including visibility assertions and a browser evaluation round trip; it is neither CPU nor paint latency. Full first-native-input→scenario-end improves 159/168→155.5/167 ms, and last-input→last-mutation improves 2→1 ms (p95 stays 2). Last-input→scenario-end is 9→10 ms with 12 ms p95 unchanged. Warm last-input→last-mutation p95 is 3→4 ms (the control is also 4 ms), while final-input completion p95 remains 11 ms. WebKit first-open readiness improves 90/92→88/91 ms. An earlier commit mechanically lengthens the measured tail, but its full cause is not proved; this is not described as a harness-only interval or an all-final-key-latency win.
A separate final-head WebKit diagnostic (one base/head/base triplet per first/warm flow, 6/6 pass, trace overhead included) confirms a mixed rendering/protocol tail. First-open head has one post-mutation style pass and three short layout records, matching controls; tail ScriptProfiler elapsed union is 0.715 ms versus 1.143/0.692 ms, not CPU. Its sampled paint is later (+7.24 ms versus +4.76/+5.81 ms from the final native input). First-phase recording adds its own calls, so diagnostic timings are not pooled with or used to replace untraced results. The small final-key/paint uncertainty is accepted with improving whole-action metrics; no pure-harness or universal-latency claim.
The independent evidence review verifies source maps, all captured asset hashes, result hashes and arithmetic. No failed/slow observations are excluded.
Validation and size
The existing focused checks pass on the identical range implementation: 8 unit tests, 18 Chromium browser tests and 18 WebKit browser tests. Full exact-head PR CI is required after this update. The previous profile-page failure was not attributed inherited: #190033 fixed the unconfigured-channel runtime load, and its exact-head full CI passed before merging.
Previous exact-head byte/static checks:
pnpm tsgo:uiand productionpnpm deadcode:knippass. Both exact source builds and strict checks pass on basec2a39e4c5a8166d1f5ea6703d1dfaa7d7c45de79and heada5611941f0379b5d96b18ba25a64ead45c5dad72: startup JS 89,596→89,607 B gzip (+11 B, within the 64 B build-variance allowance); startup CSS 34,184→34,184 B, one request; Chat JS 1,273,453→1,273,290 B; New JS 782,206→781,793 B. No budget exception or new ignore.Production LOC 807→830; browser test 457→465; full own diff +33/−2. The extra code reuses the existing index and preserves small-list behavior. Solid refactor census:
createMemo21→22; other imperative API counts unchanged. Independent P0–P2 code review is scoped-clean; the final range patch hash isb958cbf87cbfb3c51bdddea06d3bf64f7d224781da1af8360a744834910a0cce.Reproduce with
scripts/bench-control-ui-interactions.ts --steps model-picker-first-open-search,model-picker-open-search --viewport mobile --pairs 20 --counterbalance --cpu-throttle 6 --low-memory --thread-cpu-time --renderer-process-metrics, frozen base/head/base bundles; repeat at rates 1 and 4. WebKit usesscripts/bench-control-ui-engines.ts --engines webkit --network-profiles localhost --viewport mobile --pairs 20with the same steps/bundles. Counts are separate--function-countsruns.Visual proof
Inspected synthetic captures are pixel-identical. Host tags, classes and selectors are unchanged.
Release-note context: less repeated work when opening and searching a large model catalog on slower devices.
Current integration
Merged main at
c2bbb1059f85c3fe542e1f6620dea0e6bd4f18b2, including the independent browser-boundary repair #190089. Current head is23ad064b71498c0b56c510895150f973c4b9e6a5; the complete three-file picker diff retains SHA-256b958cbf87cbfb3c51bdddea06d3bf64f7d224781da1af8360a744834910a0cce. Earlier timing, byte and review evidence retains its stated source pins. Current-head UI types and production Knip pass. Both production builds and the strict base/head comparison pass: startup JS 90,271→90,270 B gzip, startup CSS 34,188→34,188 B / one request, Chat JS 1,274,111→1,273,661 B, New JS 782,441→782,054 B. Neither build has budget violations. Exact-head full CI 41277424144 passed. Native confirmed-cancelled replacement recovery merged this head as 076b925; the receipt and native cleanup are complete.Final landed-source 6× snapshot
After landing, the retained production bundle from
23ad064b71498c0b56c510895150f973c4b9e6a5(UI sources match merge076b9257b799af025ccc8474e336caf53703dfc5) passed all 140 observations in ten counterbalanced A/A pairs across the seven scoped flows. Mobile/touch, headless Chromium6×, 128MiB V8 old-space; host load7.16–13.56. This is an absolute snapshot, not another improvement claim.All seven task medians remain above300ms. Warm picker A/A median+6.26% is outside the5% timing band; do not use this snapshot for a new gain claim. The paired acceptance results above remain separately pinned. A V8 heap limit does not reproduce Android OS memory pressure.