From 8fac69bcb6038caf44213f409c79a04227b8baa5 Mon Sep 17 00:00:00 2001 From: 0xcb9ff9 <0xcb9ff9@proton.me> Date: Mon, 17 Oct 2022 11:42:09 +0800 Subject: [PATCH] parameter adjustment --- network/gossip.go | 6 +++--- network/server.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/network/gossip.go b/network/gossip.go index 4503b039da..515e03bc97 100644 --- a/network/gossip.go +++ b/network/gossip.go @@ -21,8 +21,8 @@ const ( subscribeOutputBufferSize = 1024 ) -// max worker number (min 1 and max 32) -var workerNum = int(common.Min(common.Max(uint64(runtime.NumCPU()), 1), 32)) +// max worker number (min 2 and max 64) +var workerNum = int(common.Min(common.Max(uint64(runtime.NumCPU()), 2), 64)) type Topic struct { logger hclog.Logger @@ -74,7 +74,7 @@ func (t *Topic) readLoop(sub *pubsub.Subscription, handler func(obj interface{}) ctx, cancelFn := context.WithCancel(context.Background()) defer cancelFn() - workqueue := make(chan proto.Message, workerNum) + workqueue := make(chan proto.Message, workerNum*4) defer close(workqueue) t.wg.Add(1) diff --git a/network/server.go b/network/server.go index 188bea1f2c..c05a6c376c 100644 --- a/network/server.go +++ b/network/server.go @@ -38,7 +38,7 @@ const ( // validateBufferSize is the size of validate buffers in go-libp2p-pubsub // we should have enough capacity of the queue // because when queue is full, validation is throttled and new messages are dropped. - validateBufferSize = 1024 + validateBufferSize = subscribeOutputBufferSize * 2 ) const (