perf(skill-registry): bound-concurrent catalog source fan-out
Summary
skill_registry::ops::browse_catalognow fetches each enabled registry source's index JSON with a bounded-concurrentbufferedfan-out (K=4) instead of one strictly-serialawaitper source.- Output-identical to the old serial loop:
bufferedyields per-source results in input order, so the accumulatedCatalogEntrylist (sorted afterwards) and the diagnosticerrorslist match exactly, and a failing source still contributes zero entries while being recorded inerrors. - Cold catalog loads (cache miss /
force_refresh) on the Skills browse UI now resolve all sources in ~ceil(N/4)round-trips instead of N. Cached loads are unaffected (early return before any fetch).
Problem
browse_catalog builds a reqwest::Client, then awaits each enabled source one at a time:
for source in &enabled {
match fetch_source_catalog(&client, source).await {
Ok(entries) => all_entries.extend(entries),
Err(e) => errors.push(format!("{}: {e}", source.id)),
}
}
Each source is an independent GitHub raw HTTP GET. The enabled set is the 3 bundled defaults (all enabled: true) plus any user-added custom sources, so a cold load blocked for the sum of every source's round-trip before the catalog could render.
Solution
Introduce a narrow, testable seam — a CatalogFetcher trait — over the concrete reqwest fetch, then drive the per-source fetches through a bounded buffered:
HttpCatalogFetcheris the real impl (delegates to the unchangedfetch_source_catalog).collect_catalogsmaterializes the per-source futures into aVec, runs them throughfutures::stream::iter(..).buffered(CATALOG_FETCH_CONCURRENCY), and folds the in-order results into(entries, errors)— the same accumulation the serial loop did.
Key parity points:
- Output-identical:
buffered(K)emits result[i] for input[i], so the pre-sort entry order and theerrorsorder match the serial loop;browse_catalogthen applies the samesort_by(stars desc, name asc)and the same "all sources failed" aggregation as before. - Error semantics preserved: a failed source logs a warn and is pushed to
errors; surviving sources are unaffected. - Bounded:
CATALOG_FETCH_CONCURRENCY = 4caps sockets; the enabled set is tiny (3 defaults + custom). - HRTB: the futures are collected into a
Vecbeforestream::iter— a lazyMapadaptor trips the "implementation ofSendis not general enough" error.
Submission Checklist
- [x] Tests added (happy path + edge cases):
collect_catalogs_preserves_source_order(5 sources > K, asserts input order),collect_catalogs_runs_sources_concurrently(asserts observed max in-flight > 1, i.e. real overlap),collect_catalogs_isolates_failed_source(middle source errors → drops out, survivors keep order, error recorded). The module previously had no tests. - [x] Diff coverage ≥ 80%: the fan-out driver and per-source success/failure aggregation are exercised by the fake-fetcher tests; only the ~3-line real reqwest
HttpCatalogFetcher::fetchremains client-bound (untestable without a live HTTP endpoint). - [x] No new external network dependencies (same
fetch_source_catalog, just concurrent). - [x] N/A: no linked issue — proactive performance improvement.
Impact
- Runtime: Rust core skill registry (
browse_catalog), user-facing Skills browse UI on cold loads. - Latency: a cold catalog load over N sources now resolves in ~
ceil(N/4)round-trips instead of N. No change for cache hits. - No migration, security, or compatibility implications; per-source fetch, parse, sort, caching, and the "all failed" error path are untouched.
Parity Contract
- Legacy behaviour preserved: each source goes through the identical
fetch_source_catalog→ parse path; the final sort, cache write, and "all registry sources failed" aggregation are unchanged. - Guard/fallback parity: the cache short-circuit, the empty-enabled early return, and the per-source error isolation all run exactly as before.
Summary by CodeRabbit
- Performance
- Skill catalogs now fetch concurrently from multiple sources, reducing load times.
- Reliability
- Partial source failures are isolated—failed sources no longer block others and produce per-source error messages.
- Behavior
- Catalog order and downstream sorting/cache behavior are preserved.
- Tests
- Added tests validating concurrent fetching, order preservation, and failure isolation.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 475bbc3f-1cef-4e00-8398-7957224f8fba
📥 Commits
Reviewing files that changed from the base of the PR and between ad31a8fc7a44affa1044e98f56d7b1b50a818611 and 40d3b203c9f18e7540fee648f0042b27ea7d2737.
📒 Files selected for processing (1)
src/openhuman/skill_registry/ops.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- src/openhuman/skill_registry/ops.rs
📝 Walkthrough
Walkthrough
Replaces sequential per-source catalog fetches with a bounded-concurrency fan-out: adds a CatalogFetcher trait, HttpCatalogFetcher, and collect_catalogs helper; updates browse_catalog to use the helper; adds tests for order, concurrency, and error isolation.
Changes
Concurrent Catalog Fetching
| Layer / File(s) | Summary |
|---|---|
Dependencies and concurrency configuration src/openhuman/skill_registry/ops.rs |
Adds async_trait and StreamExt imports and defines CATALOG_FETCH_CONCURRENCY constant to configure bounded in-flight fetch limits. |
Catalog fetcher abstraction and concurrent implementation src/openhuman/skill_registry/ops.rs |
Defines CatalogFetcher trait, provides HttpCatalogFetcher, and implements collect_catalogs which performs bounded-concurrency fetches with buffered(CATALOG_FETCH_CONCURRENCY), aggregates entries, collects per-source error strings, and preserves input order. |
Integration into browse_catalog function src/openhuman/skill_registry/ops.rs |
Updates browse_catalog to call collect_catalogs with HttpCatalogFetcher instead of awaiting each source sequentially, keeping sorting, cache save, and overall error behavior unchanged. |
Unit tests for concurrent catalog fetching src/openhuman/skill_registry/ops.rs |
Adds #[cfg(test)] module with FakeFetcher and three tokio::test cases verifying order preservation, observable concurrent overlap, and per-source failure isolation with error reporting. |
Estimated Code Review Effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
A rabbit once fetched catalogs one-by-one, so slow,
Now traits and buffers help the fetches grow!
They leap in parallel, keeping order tight,
Failures reported, each source held light.
🐇✨
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title 'perf(skill-registry): bound-concurrent catalog source fan-out' directly and clearly describes the main change: implementing bounded-concurrent fetching of catalog sources instead of sequential awaits. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 84.62% which is sufficient. The required threshold is 80.00%. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
Closing as obsolete. Since this PR was opened, skill_registry was restructured on main by #3481 (split registry/runtime modules) and #3607 (single-flight + stale-while-revalidate catalog loading). The multi-source fan-out this PR optimized no longer exists: browse_catalog now fetches a single catalog_url() in fetch_catalog_uncached — there is no per-source loop left to bound, so the change is superseded. Thanks @sanil-23 for the single-flight rework.