Skip to content

perf(models): speed up multi-provider catalog refreshes - #167101

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-micro-prepared-model-catalog-build-speed-20260919
Oct 8, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-micro-prepared-model-catalog-build-speed-20260919

Conversation

@steipete

@steipete steipete commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Refreshing several provider catalogs waits for independent network discovery hooks in sequence, extending model-picker refresh time.

User Impact

Multi-provider catalog refreshes finish sooner while preserving provider selection, per-provider deadlines, authentication ownership, model precedence, and failure handling. No configuration or schema changes.

Why This Change Was Made

Run up to four catalog hooks concurrently within each discovery phase, then merge rows and outcomes in their original label order. Each phase settles before the next starts, and admitted tasks settle before a failure propagates. The existing concurrency runner owns scheduling.

Prepare discovery groups and provider-owner counts once per acquisition instead of four times. Remove the old serial orchestration, duplicate phase-order constant, and one-use merge wrapper; reuse the existing provider-reference matcher for synthetic auth. Production delta: −13 lines (157 added, 170 removed; tests/docs excluded).

This complements #167008, which owns refresh frequency and shared normalization. The existing worker retains registrations, scopes provider refreshes, and retains unchanged catalog publications; this change adds no cache.

Evidence

Same-host Linux source-worker comparison on main 54bd6ecee1897f51b2963b6ea4c165a356e2d805, including #167008. Eight synthetic provider plugins serve 500 models each over loopback HTTP with 150 ms response latency. Both variants return 4,000 models; full builds make eight requests and selected-provider refreshes make one.

Measurement Serial baseline Candidate
Warm full build 1,837 ms 907 ms
Discovery/source phase 1,265 ms 338 ms
Catalog facts/normalization 341 ms 352 ms
Publication preparation 23.6 ms 23.1 ms
Repeat single-provider refresh 219 ms 223 ms
Cold source-worker build 11,826 ms 10,924 ms

Warm full builds are 2.03× faster, with 3.75× faster discovery. Warm registry preparation remains below 1 ms and auth preparation about 3.5 ms. The single-provider target of 300 ms is met in both variants; this patch does not claim a single-provider speedup. The 1.5 s cold-build target is missed: source-worker startup dominates. Warm process-wide RSS was approximately 846 → 878 MiB across separate processes; this is not an allocation profile or a claimed memory improvement.

The fake-time regression fails on original code (peak concurrency 1 rather than 4), and passes on the candidate. It covers slot reuse, out-of-order completion, deterministic row/outcome precedence, and phase separation. Its single-worker command took 47.78 s including shared worker compilation, with 1.05 s test time; the new case took 566 ms.

Validation Result
node scripts/check-changed.mjs --staged on isolated Linux rig, original base c531ab224174d94e78e803de46355915298ab477 Passed, including all 27 test type graphs, lint, dead exports, runtime cycles, and repository guards
Rebased candidate: provider/catalog/concurrency siblings plus real worker reuse 142 tests in 16 files passed; 126.18 s command wall time
Rebased candidate: real Gateway catalog freshness All three cases passed, including explicit refresh, unchanged publication identity, failed siblings, and getter-backed results
Runtime build required by Gateway proof Passed; 70.1 s
Independent Codex review Scoped-clean through P2; no actionable findings
Published-head CI Run 37758721216 passed: 36 successful jobs, 25 skipped, no failures; 624 s workflow wall time and 1,509 aggregate Node-test job-seconds

Published head ca511b4f4ef551d2f28c49256c53f8298d72e396 is based on main 739182bca6b56c723179f0a4947fa38eb2e623ae. The final rebase adds only disjoint upstream changes. The rebase preserved patch ID 5dd974e64b2dfabea58faee9a4d2528cbad62c86. The completed broad gate is prior-base evidence; the changed catalog-owner context was checked by the rebased tests and repeated measurement above.

A separate existing models-list.discovery-lifecycle.integration.test.ts failed before issuing its expected lifecycle-b HTTP request on both original base and candidate. A minimal-Gateway-mode probe did not repair it and was discarded; no test assertion was relaxed. Gateway membership, worker recovery, and remote-catalog siblings passed five tests in three files. The native-lifecycle sibling reported two 120 s timeouts and one missing-model assertion; all three failures reproduced in the same four-file order on clean main 739182bca6b56c723179f0a4947fa38eb2e623ae (357.95 s including its runtime build). The discovery-lifecycle failure also reproduced on that exact clean main (56.70 s). These tests are unchanged by this PR; their root causes remain unresolved. Final-head CI passed; the inherited local failures remain recorded separately. The ad hoc 4,000-row Gateway probe also did not establish admission and is not presented as successful end-to-end timing. No production Gateway latency or allocation improvement is claimed.

Remote execution: Blacksmith Testbox tbx_01m4d046d3tfwnt2krz2cdn1x0 supplied initial baseline/negative-control evidence before a sync failure; replacement tbx_01m4d29ck84s3rhg0vqqktxy5z remained queued. AWS cbx_37412f4fa4c5 was quota-downsized and released unused. Hetzner cbx_35aeba87e13e verified source hashes and checks, then lost command transport after 21 passing type graphs. All leases were stopped. Final proof ran on the authorized isolated Linux rig with task-local state and TMPDIR, under nice -n 10 ionice -c3; no heavy validation ran on the development Mac.

Merged as de2b8ae04af1623cbb5b72e84bb80976008b784f; verified on main with the same patch ID as the reviewed candidate.

Acquire independent provider catalogs with bounded concurrency within each discovery phase. Preserve label-ordered model and outcome precedence, settle admitted hooks on failure, and reuse the shared concurrency runner.
@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: M labels Oct 8, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 8, 2026
@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 8, 2026, 5:50 AM ET / 09:50 UTC (Revision 2).

ClawSweeper review

What this changes

The branch runs up to four provider catalog hooks concurrently within each discovery phase while preserving ordered model and outcome merging.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, focused performance patch with credible production-boundary evidence and no identified correctness defect.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied Linux comparison exercises the production catalog source worker with real loopback HTTP and observes faster multi-provider acquisition with unchanged model and request counts; rebased Gateway RPC freshness cases exercise publication and failed siblings. This supports the scoped scheduling change, without proving production Gateway latency or memory improvement. No stored-data contract changes require migration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes
User problem: Refreshing several provider catalogs makes users wait for independent network requests to finish one after another.
Reason: The measured multi-provider benefit exceeds the cost of this focused change. Prior merged area ownership and the author’s explicit scheduling rationale establish direction without another product decision.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main still performs serial provider discovery. The bounded concurrency change has credible runtime evidence, preserves deterministic publication, and has no actionable review findings.

Priority: P2
Reviewed head: ca511b4f4ef551d2f28c49256c53f8298d72e396

Before merge

None.

Findings

None.

Agent review details

How this fits together

Provider catalog discovery collects available models from configured provider plugins for OpenClaw’s model inventory. It combines discovered rows with authored settings and publishes provider outcomes to the existing catalog owner.

flowchart TD
  A[Configured providers and credentials] --> B[Provider scope and endpoint eligibility]
  B --> C[Ordered discovery phases]
  C --> D[Up to four concurrent catalog hooks]
  D --> E[Wait for phase settlement]
  E --> F[Merge rows and outcomes in label order]
  F --> G[Published model inventory]
Loading

Technical review

Best possible solution:

Keep bounded acquisition in the existing discovery owner and retain the existing scope, credential, phase, and publication contracts.

Do we have a high-confidence way to reproduce the issue?

Not applicable as a correctness bug; serial discovery is source-verifiable, and the supplied real-worker comparison provides a concrete way to measure its performance cost.

Is this the best way to solve the issue?

Yes. Reusing the shared concurrency runner at the existing acquisition owner is a focused solution that removes serial orchestration without adding another cache or publication owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against d3309e576011.

Provenance checked

  • src/agents/models-config.providers.implicit.ts: discovery orchestration changes intended behavior with a stated reason (7db79b0: The earliest traced file history split provider discovery helpers; its commit message does not explain why hooks were serial. The commit-to-PR lookup returned no associated PR.)
  • src/agents/models-config.providers.implicit.ts: configured-model merge keeps the original intent (1c5a4d2: The commit states that implicit provider discovery merges were stabilized; subsequent merged changes preserve explicit model authority and discovered metadata.)
  • src/agents/models-config.providers.implicit.ts: provider outcomes keeps the original intent (fix(models): retain compatible catalogs after refresh failures #139357: Retain compatible learned inventory after failed refreshes while keeping current failure outcomes and allowing successful responses, including empty results, to replace membership.)
  • src/agents/models-config.providers.implicit.ts: synthetic-auth reference matching keeps the original intent (b918568: The associated xAI repair reconciled provider authentication and Responses wiring; the current change replaces local normalized alias matching with the existing shared matcher.)

Testing

Proof path: shipped entry point. Added test files: 1.

Security

None.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

PR surface

Source -13, Tests +102, Docs +5. Total +94 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 157 170 -13
Tests 1 102 0 +102
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 264 170 +94

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded model-inventory performance improvement with measured benefit for multi-provider refreshes.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-08T09:39:10.203Z sha ca511b4 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review October 8, 2026 09:44
@steipete
steipete enabled auto-merge (squash) October 8, 2026 09:46
@steipete
steipete merged commit de2b8ae into main Oct 8, 2026
200 of 203 checks passed
@steipete
steipete deleted the steipete/perf-micro-prepared-model-catalog-build-speed-20260919 branch October 8, 2026 09:56
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 9, 2026
Acquire independent provider catalogs with bounded concurrency within each discovery phase. Preserve label-ordered model and outcome precedence, settle admitted hooks on failure, and reuse the shared concurrency runner.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant