fix(input): smaller chainsync block batch#638
Conversation
Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
📝 WalkthroughWalkthroughThe pull request modifies the chainsync component to adjust configuration parameters for improved message queuing during catch-up synchronization. The blockBatchSize constant is reduced from 500 to 50, the eventChan buffer is increased from 10 to 2048, and receive queue sizes are added to both Chainsync (100) and BlockFetch (512) configurations. These changes are accompanied by comments explaining their purpose in preventing backpressure and message queue limit errors during rapid block synchronization. Possibly related PRs
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
input/chainsync/chainsync.go (1)
163-166: Derive channel capacity from sync constants to avoid future tuning drift.
Line 166hard-codes2048, but this is operationally coupled toblockBatchSizeand pipeline behavior. Encoding that relation in constants will make future tuning safer.♻️ Proposed refactor
const ( // Size of cache for recent chainsync cursors cursorCacheSize = 20 // blockBatchSize controls how many blocks are requested per GetBlockRange // call during NtN catch-up sync. Must be small enough that the events // generated (~20 per block) fit in the eventChan buffer to avoid // backpressure that stalls the blockfetch recv queue and triggers // "message queue limit exceeded" errors. blockBatchSize = 50 + estimatedEventsPerBlock = 20 + eventChanBufferSize = blockBatchSize * estimatedEventsPerBlock * 2 + chainSyncPipelineLimit = 50 + chainSyncRecvQueueSize = chainSyncPipelineLimit * 2 maxAutoReconnectDelay = 60 * time.Second defaultKupoTimeout = 30 * time.Second ) @@ - c.eventChan = make(chan event.Event, 2048) + c.eventChan = make(chan event.Event, eventChanBufferSize) @@ - ochainsync.WithPipelineLimit(50), + ochainsync.WithPipelineLimit(chainSyncPipelineLimit), // Recv queue must exceed pipeline limit to avoid "message queue // limit exceeded" errors during rapid catch-up sync - ochainsync.WithRecvQueueSize(100), + ochainsync.WithRecvQueueSize(chainSyncRecvQueueSize),🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@input/chainsync/chainsync.go` around lines 163 - 166, Replace the hard-coded channel size when creating c.eventChan with a capacity computed from the sync tuning constants (e.g., blockBatchSize and PipelineLimit) so the buffer scales with those parameters; locate the c.eventChan = make(chan event.Event, 2048) allocation and change it to compute capacity like (blockBatchSize * PipelineLimit * <smallFactor>) or a similarly named constant derived from blockBatchSize to preserve headroom, and ensure any new constant(s) are named clearly (e.g., eventChannelMultiplier or eventBufferCapacity) and used in the allocation so future tuning of blockBatchSize/PipelineLimit automatically adjusts the channel size.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@input/chainsync/chainsync.go`:
- Around line 163-166: Replace the hard-coded channel size when creating
c.eventChan with a capacity computed from the sync tuning constants (e.g.,
blockBatchSize and PipelineLimit) so the buffer scales with those parameters;
locate the c.eventChan = make(chan event.Event, 2048) allocation and change it
to compute capacity like (blockBatchSize * PipelineLimit * <smallFactor>) or a
similarly named constant derived from blockBatchSize to preserve headroom, and
ensure any new constant(s) are named clearly (e.g., eventChannelMultiplier or
eventBufferCapacity) and used in the allocation so future tuning of
blockBatchSize/PipelineLimit automatically adjusts the channel size.
Summary by cubic
Reduce chainsync block batch size and enlarge internal queues to prevent backpressure and “message queue limit exceeded” errors during catch-up sync. Improves Node-to-Node sync stability.
Written for commit 6029d04. Summary will update on new commits.
Summary by CodeRabbit
Release Notes