Repository navigation
perf(models): reduce catalog normalization allocations - #198591
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: needs changes before merge. What this changesThis PR reuses provider selections within each synchronous model-catalog normalization pass. Example: The reported built-worker workload refreshes catalogs across two workspaces and two providers.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep open: this maintainer-authored optimization shows useful allocation savings, but its new test fixture violates the provider-registry return type. Priority: P2 Before merge
Findings
Agent review detailsHow this fits togetherModel discovery passes registry rows through provider model and transport hooks, then compatibility normalization, before returning catalog models. flowchart LR
A[Model registry rows] --> B[Catalog normalization pass]
B --> C[Existing provider runtime handles]
C --> D[Provider model hooks]
D --> E[Transport normalization]
E --> F[Compatibility normalization]
F --> G[Normalized catalog models]
Technical reviewBest possible solution: Keep the pass-local reuse and have the PR author return workspaceDir from the typed registry fixture. Do we have a high-confidence way to reproduce the issue? Source inspection establishes the missing required workspaceDir property at the directly typed resolver injection; no target code or tests were executed during this read-only review. Is this the best way to solve the issue? The optimization follows the existing provider-selection owner and bounds reuse to one synchronous pass, preserving per-model hook execution without persistent cache or configuration changes. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 5765898e1a29. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
PR surfaceSource +52, Tests +170. Total +222 across 6 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes: No label 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 November 13, 2026, 10:20 PM ET / November 14, 2026, 03:20 UTC. |
|
Merged via squash auto-merge.
|
* perf(models): reuse provider selection within catalog normalization * test(models): exercise catalog transport changes * style(models): satisfy catalog fixture block rule * test(models): carry workspace in provider registry fixture
|
Type- aware type-aware fixture-link what type of updates are usually available? I have over 300 apps right now, 230 android apps what should be updated vs not updated? Thank you |
What Problem This Solves
Refreshing large model catalogs repeatedly resolves the same provider hooks for every model, creating avoidable worker allocation and CPU pressure.
User Impact
The measured two-provider catalog workload allocates 39% less memory per refresh, runs warm requests 16% faster, and retains 3.51 MiB less worker heap. Cold-request median is effectively unchanged. No new setting, disabled feature, worker-pool consolidation, or persistent cache.
Why This Change Was Made
Reuse successful provider selections within one synchronous catalog pass, then discard them. Existing handle logic retries model-specific misses. Every model still runs its hooks; configured-provider isolation, in-place model updates, fallback order, and same-origin transport restrictions remain intact.
Evidence
Validation
sourcePerformancebuilds passed, including built plugin/control-plane checks. This profile does not claim full package/release qualification.f0e58c37cdb7with no actionable findings; independent source review also found no remaining issue.e68e8ab3c854; later commits only correct the test fixture. Final headcc462fa2cab4passes all four normalization tests, type-aware fixture lint, and the exactcore.test.plugins-platformTypeScript leaf that caught a missingworkspaceDirfield in CI. Production inputs are identical, so the benchmark and broader behavioral proof remain valid.models.listreads still serve published rows while catalog discovery refreshes in the background. This PR adds no RPC wait or UI loading state. Existing first-snapshot picker loading presentation is a separate follow-up.Benchmark
Frozen base:
9cb3c14855e5a5216148a1c125f9240c5da1f6de. The acceptance rule was recorded here before comparisons: at least 15% lower median warm allocated bytes, identical catalog/runtime hashes, and no 20% median/p95 latency or retained-heap regression. All measured metrics meet it.40 independent built-worker runs: five AB allocation pairs, five AB retained-heap pairs, and ten timing pairs (five AB plus five BA). Each run uses two workspaces, two providers, 5,000 overlay rows, 1,000 discovered rows per provider, and four task rounds. There are seven warm requests after the first cold request. Sampling and timing runs are separate. All catalog and runtime hashes match.
Allocation corresponds to 100.79 → 61.18 MiB per warm request. The first allocation profiles attribute 154.61 → 0.06 MiB to provider-selection preparation and 57.45 → 0.06 MiB to runtime lookup preparation.
Ranges: warm requests 48.88–220.94 → 39.07–175.29 ms; cold requests 654.65–1712.95 → 728.44–1557.50 ms; allocation 696.18–707.25 → 416.92–434.71 MiB; retained worker heap 74.34–74.43 → 70.84–70.91 MiB. Host load ranged 7.8–15.8. The initial five AB timing pairs showed a 7.2% slower cold median; five BA pairs were declared before running to counterbalance order, and every original sample remains in the combined results.
Reproduction, for each base/candidate build:
Add
--sample-allocationfor the allocation pass. Omit--measure-tasksfor post-GC retained-heap collection after each round.This exercises the real catalog worker, not a full Gateway/client workload. Process RSS includes the TypeScript harness; the isolated retained-worker-heap result is the useful residency comparison. No claim of 39% lower Gateway RSS.