perf(stellar): pipeline streaming scan to overlap RPC fetch with decrypt#154
Open
collinsezedike wants to merge 1 commit into
Open
Conversation
|
@collinsezedike Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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
pipeline(source, capacity)helper insrc/chains/stellar/scanner/pipeline.ts. A background pump keeps pulling fromsourceup tocapacityitems ahead of the consumer, so the next RPC fetch's I/O is already in flight while the consumer does CPU-bound work on already-buffered items, instead of alternating "await a full window, then process it."scanAnnouncementsStreamnow wraps itssourceinpipeline(source, window)instead of prefetching a strict window before scanning any of it. Peak memory stays O(window); cancellation and error propagation are unchanged.scanAnnouncementsStreamSequentialfor benchmark comparisons, matching howscanAnnouncementsLegacySharedSecretTagis retained for the view-tag-batching benchmark.test/chains/stellar/bench/scan.bench.ts, which had corrupted/duplicated content ondevelop(left over from an earlier merge) making it fail to even parse — unrelated to this change but blocking it since I needed to extend that file.docs/chains/stellar-streaming-scan-pipeline.md, changelog entry under the upcoming release.Closes #126.
Semver
Additive-only: new internal module (
src/chains/stellar/scanner/, not part of the public package exports) plus a new benchmark-only exportscanAnnouncementsStreamSequential.fetchAnnouncementsStreamandscanAnnouncementsStream's public signatures and behavior are unchanged.Test plan
pnpm buildpnpm test— full suite passes (793 passed in the Stellar module, no regressions)test/chains/stellar/scanner/pipeline.test.ts(runs underpnpm test, not excluded likebench/): order preservation, overlap timing (pipelined run is reliably ≥25% faster than a measured sequential baseline with matched I/O/CPU delays), backpressure bound with a fast producer + slow consumer, cancellation propagation, error propagationtest/chains/stellar/bench/scan.bench.ts— new "Stellar streaming scan pipelining" section: correctness test plusbefore/afterbenchmarks against a mock paginated RPC source; measured 36% wall-clock reduction on the 10k-announcement canned dataset (537ms → 343ms), clearing the 30% targetscanAnnouncementsStreamtests (window sizing, cancellation, memory-bounded) pass unmodifiedpnpm format:check