Repository navigation
perf: parallelize and merge /api/pools queries - #6
Merged
Merged
Conversation
GetPools() and GetPoolInfoAsync() chained ~9-10 sequential per-pool DB round trips; with 12+ enabled pools this made /api/pools take ~5s to answer (confirmed: /metrics ~25ms, /api/pools ~5.4s with no slow or blocked queries in pg_stat_activity, so it was round-trip count, not query cost). - Run the independent per-pool queries concurrently via Task.WhenAll instead of awaiting them one at a time. Only GetEffortBetweenCreatedAsync stays sequential, since it depends on the batch's lastBlockTime result. - Collapse 5 block queries (count/confirmed/pending/last reward/last time) into one GetPoolBlockSummaryAsync, and 2 aux-block queries into one GetPoolAuxBlockSummaryAsync. Verified both against live data, including the zero-blocks edge case. Per-pool query count for /api/pools drops from ~10 to 5, now run concurrently instead of chained. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This was referenced Nov 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/api/poolswas taking ~5.4s per request (metrics endpoint ~25ms, no slow/blocked queries in pg_stat_activity — pure round-trip count).Task.WhenAllinstead of chaining ~9-10 sequentialawaits, in bothGetPools()andGetPoolInfoAsync().GetPoolBlockSummaryAsync, and 2 aux-block queries into oneGetPoolAuxBlockSummaryAsync. Verified both against live data on .100, including the zero-blocks edge case.Test plan
dotnet build -c Release --framework net10.0clean, 0 errorsminingcorePostgres DB (populated pool + empty pool)/api/poolsagainst the live server after deploy🤖 Generated with Claude Code