From e021971c563eb4f409675bce52398ebd9597416f Mon Sep 17 00:00:00 2001 From: "Masih H. Derkani" Date: Thu, 28 Nov 2024 15:22:43 +0000 Subject: [PATCH] Increase message and subscription buffer size to 128 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 --- host.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/host.go b/host.go index 89d198fc..995e48ac 100644 --- a/host.go +++ b/host.go @@ -211,7 +211,6 @@ func (h *gpbftRunner) Start(ctx context.Context) (_err error) { case <-h.runningCtx.Done(): return nil } - } return nil }) @@ -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()