Add block fetch prefetch pipeline and improve shutdown consistency#46
Closed
freemans13 wants to merge 2 commits into
Closed
Conversation
Decouple network block fetching from worker distribution using a two-goroutine pipeline. This keeps the network connection saturated even when validation is slower than fetch, improving overall catchup performance. Changes: - Add batchFetchWithPrefetch and distributeBatchesToWorkers functions - Introduce FetchPrefetchDepth setting (default: 5 batches ahead) - Add context cancellation check in subtree validation level processing The fetcher can now run up to prefetchDepth batches ahead of distribution, maximizing network throughput during block catchup operations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Merged
7 tasks
7 tasks
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
This PR introduces two major improvements:
1. Block Fetch Prefetch Pipeline
Adds a configurable prefetch mechanism that decouples block fetching from validation processing, allowing the network pipeline to stay full while validation processes earlier batches. This significantly improves catchup throughput.
Key changes:
FetchPrefetchDepthsetting (default: 5 batches) to control how far ahead fetching runsbatchFetchWithPrefetch()anddistributeBatchesToWorkers()for pipeline architectureprefetchDepth=02. Improved Shutdown Consistency
Enhances graceful shutdown behavior across GRPC and Kafka consumer to prevent hangs and race conditions.
GRPC improvements (
util/grpc.go):Stop()if graceful shutdown hangsKafka consumer improvements (
util/kafka/kafka_consumer.go):Subtree validation improvements (
services/subtreevalidation/check_block_subtrees.go):Test Plan
prefetchDepth=0to ensure backward compatibility🤖 Generated with Claude Code