Skip to content

perf: optimize range API with streaming & prefetch - #108

Open
notTanveer wants to merge 6 commits into
CypherCommons:mainfrom
notTanveer:perf/optimize-range-api
Open

perf: optimize range API with streaming & prefetch#108
notTanveer wants to merge 6 commits into
CypherCommons:mainfrom
notTanveer:perf/optimize-range-api

Conversation

@notTanveer

@notTanveer notTanveer commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Streaming range endpoint: Replace full-buffer approach with chunked byte streaming and Cache-Control headers.
  • Block prefetch: Prefetch the next block in both Bitcoin Core and Esplora providers to hide RPC/HTTP latency during sequential scans
  • Binary precomputation: Precompute and store silent block data in binary format at index time, eliminating per-request serialization
  • WebSocket streaming sync: Add filterSpent support and batched binary framing to the WS gateway for efficient wallet sync

Benchmark Results (tested with shroud)

Architecture 50-Block Sync Time Client Throughput Payload per 1,000 Blocks
V1: REST JSON (filterSpent=true) ~6.00s ~2,500 tx/sec ~20 MB
V2: REST Binary (Unfiltered) ~1.50s ~16,700 tx/sec ~58 MB
V3: REST Binary (filterSpent=true) ~2.00s ~9,500 tx/sec * ~12 MB
V4: WebSocket Binary Streaming (Current) < 0.50s ~20,000 tx/sec ~12 MB

Key Wins

  1. Network Pipelining: WebSocket streaming eliminates the HTTP overhead and constant polling latency.
  2. Maximum Wasm Efficiency: The Rust WebAssembly engine is now parsing heavily filtered UTXOs at a blistering 20,000 transactions per second. Batch scanning consistently finishes in ~570ms for massive 1.5MB chunks.
  3. Bandwidth Reduction: Implementing filterSpent=true strictly on the binary endpoint reduced sync payload size by ~80%, avoiding the Base64/JSON serialization tax entirely.
image

@notTanveer
notTanveer force-pushed the perf/optimize-range-api branch from df6e5bb to 04642ef Compare June 28, 2026 07:51
@notTanveer notTanveer changed the title perf: optimize range API with streaming, prefetch, and connection hardening perf: optimize range API with streaming & prefetch Jun 28, 2026
@notTanveer
notTanveer force-pushed the perf/optimize-range-api branch 2 times, most recently from c95a3cf to f4bf2ae Compare June 28, 2026 08:21
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