Skip to content

Commit

Permalink
Increase message and subscription buffer size to 128 (#762)
Browse files Browse the repository at this point in the history
Increase the pubsub and internal message queue buffer sizes to 128. This
is to allow a larger headroom for buffered messages if the internal
message handling loop is too slow, or in a case where there is a slight
missalignment across nodes on bootstrap.

Relates to #759
  • Loading branch information
masih authored Dec 3, 2024
1 parent c4d8f53 commit b4e2522
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions host.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ func (h *gpbftRunner) Start(ctx context.Context) (_err error) {
case <-h.runningCtx.Done():
return nil
}

}
return nil
})
Expand Down Expand Up @@ -553,12 +552,16 @@ func (h *gpbftRunner) startPubsub() (<-chan gpbft.ValidatedMessage, error) {
return nil, err
}

sub, err := h.topic.Subscribe()
const (
subBufferSize = 128
msgQueueBufferSize = 128
)
sub, err := h.topic.Subscribe(pubsub.WithBufferSize(subBufferSize))
if err != nil {
return nil, fmt.Errorf("could not subscribe to pubsub topic: %s: %w", sub.Topic(), err)
}

messageQueue := make(chan gpbft.ValidatedMessage, 20)
messageQueue := make(chan gpbft.ValidatedMessage, msgQueueBufferSize)
h.errgrp.Go(func() error {
defer func() {
sub.Cancel()
Expand Down

0 comments on commit b4e2522

Please sign in to comment.