fix(minibf): Fetch pool metadata in parallel - #790
Conversation
WalkthroughAdded Changes
Sequence DiagramsequenceDiagram
participant old as Old Flow
participant new as New Flow
participant svc as Service/API
rect rgb(200, 220, 255)
Note over old: Synchronous (Sequential)
old->>svc: fetch metadata pool 1
activate svc
svc-->>old: response
deactivate svc
old->>svc: fetch metadata pool 2
activate svc
svc-->>old: response
deactivate svc
old->>svc: fetch metadata pool 3
activate svc
svc-->>old: response
deactivate svc
end
rect rgb(220, 255, 220)
Note over new: Concurrent (Parallel with join_all)
par
new->>svc: fetch metadata pool 1
new->>svc: fetch metadata pool 2
new->>svc: fetch metadata pool 3
and
activate svc
svc-->>new: response 1
svc-->>new: response 2
svc-->>new: response 3
deactivate svc
end
end
Note over new: Build PoolListExtendedInner<br/>with concurrent results
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. 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 |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
crates/minibf/src/routes/pools.rs (2)
44-58: Timeout reduced to 5s; consider configurability and client reuseDropping the HTTP timeout to 5 seconds will help cap tail latency but may cause more metadata misses for slower endpoints. Since this value is now performance‑critical (and duplicated across many parallel calls), consider making it a named constant or configuration option, and reusing a shared HTTP client instead of building a new one per call to reduce connection‑pool overhead.
17-17: Parallel metadata fetch is unbounded; consider limiting concurrency and reusing the client
join_allovermetadata_futureswill issue one HTTP request per pool concurrently, and each future currently builds its own client viapool_offchain_metadata. With many pools this can mean a large, spiky number of outbound connections and client instances.It would be safer to:
- Reuse a single HTTP client for all metadata lookups, and
- Bound concurrency (e.g., with
futures::stream::iter(...).map(...).buffer_unordered(N)or a semaphore) so you still get parallelism without potentially overwhelming the host or your process.This keeps the new behavior (faster aggregate latency) while avoiding resource‑exhaustion risks.
Also applies to: 122-138, 141-141
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (2)
crates/minibf/Cargo.toml(1 hunks)crates/minibf/src/routes/pools.rs(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
crates/minibf/src/routes/pools.rs (1)
crates/minibf/src/mapping.rs (1)
bech32_pool(104-106)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Check Build
🔇 Additional comments (2)
crates/minibf/Cargo.toml (1)
27-30: futures dependency addition looks appropriateAdding
futures = "0.3.31"here matches how other direct dependencies are pinned and aligns with the newjoin_allusage inpools.rs. No manifest issues from this change; just ensure you’re not accidentally pulling in multiplefuturesmajor versions elsewhere in the workspace.crates/minibf/src/routes/pools.rs (1)
145-172: Behavior change claim is unsupported by the code changesThe review comment attributes a metadata null-handling behavior to this PR, but verification shows this behavior pre-existed before commit 4c0b875. The git diff reveals the commit only refactors metadata fetching from sequential to parallel execution using
join_all(). The identical null-handling logic (returningNone::<String>for ticker/name/description/homepage when off-chain metadata is unavailable) was already present in the parent commit. No actual API behavior change regarding metadata nulls was introduced by this PR—the refactoring is strictly mechanical.Likely an incorrect or invalid review comment.
Summary by CodeRabbit
New Features
Refactor
✏️ Tip: You can customize this high-level summary in your review settings.