Skip to content

perf: parallelize and merge /api/pools queries - #6

Merged
colneech-dev merged 1 commit into
mainfrom
perf/pools-api-parallel-queries
Nov 23, 2026
Merged

colneech-dev merged 1 commit into
mainfrom
perf/pools-api-parallel-queries

Conversation

@colneech-dev

Copy link
Copy Markdown
Owner

Summary

  • /api/pools was taking ~5.4s per request (metrics endpoint ~25ms, no slow/blocked queries in pg_stat_activity — pure round-trip count).
  • Run the independent per-pool queries concurrently via Task.WhenAll instead of chaining ~9-10 sequential awaits, in both GetPools() and GetPoolInfoAsync().
  • Collapse 5 block queries into one GetPoolBlockSummaryAsync, and 2 aux-block queries into one GetPoolAuxBlockSummaryAsync. Verified both against live data on .100, including the zero-blocks edge case.

Test plan

  • dotnet build -c Release --framework net10.0 clean, 0 errors
  • New merged SQL verified directly against the live miningcore Postgres DB (populated pool + empty pool)
  • Re-time /api/pools against the live server after deploy

🤖 Generated with Claude Code

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>
@colneech-dev
colneech-dev merged commit 8f73b0a into main Nov 23, 2026
1 check passed
@colneech-dev
colneech-dev deleted the perf/pools-api-parallel-queries branch November 23, 2026 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant