Skip to content

Commit 6513e33

Browse files
authored
fix: lower pipeline sizes (#1437)
Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
1 parent 6f27b6d commit 6513e33

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

ledger/chainsync.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,19 @@ func (ls *LedgerState) handleEventChainsync(evt event.Event) {
8181
}
8282
} else if e.BlockHeader != nil {
8383
if err := ls.handleEventChainsyncBlockHeader(e); err != nil {
84+
// Header queue full is expected during bulk sync when
85+
// pipelined headers arrive faster than blockfetch can
86+
// drain them. Log at DEBUG to avoid log spam.
87+
if errors.Is(err, chain.ErrHeaderQueueFull) {
88+
ls.config.Logger.Debug(
89+
"failed to handle block header",
90+
"component", "ledger",
91+
"error", err,
92+
"slot", e.Point.Slot,
93+
"hash", hex.EncodeToString(e.Point.Hash),
94+
)
95+
return
96+
}
8497
ls.config.Logger.Error(
8598
"failed to handle block header",
8699
"component", "ledger",

ouroboros/chainsync.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,14 @@ func (o *Ouroboros) chainsyncClientConnOpts() []ochainsync.ChainSyncOptionFunc {
4646
return []ochainsync.ChainSyncOptionFunc{
4747
ochainsync.WithRollForwardFunc(o.chainsyncClientRollForward),
4848
ochainsync.WithRollBackwardFunc(o.chainsyncClientRollBackward),
49-
// Enable pipelining of RequestNext messages to speed up chainsync
50-
ochainsync.WithPipelineLimit(50),
51-
// Set the recv queue size to 2x our pipeline limit
52-
ochainsync.WithRecvQueueSize(100),
49+
// Pipeline enough headers to keep one blockfetch batch (500
50+
// blocks) ready while the previous batch processes. A depth
51+
// of 10 is sufficient; higher values flood the header queue
52+
// and waste CPU parsing headers that are immediately dropped.
53+
ochainsync.WithPipelineLimit(10),
54+
// Recv queue at 2x pipeline limit to absorb bursts without
55+
// blocking the protocol goroutine.
56+
ochainsync.WithRecvQueueSize(20),
5357
}
5458
}
5559

0 commit comments

Comments
 (0)