From 74196b95df352e0dd9e1e997f19808e6fd3d6bb6 Mon Sep 17 00:00:00 2001 From: gammazero <11790789+gammazero@users.noreply.github.com> Date: Thu, 16 Jan 2025 22:21:38 -1000 Subject: [PATCH] reduce default number of routing in-process requests Reduce the routing ProviderQueryManager default MaxInProcessRequests from 16 to 8. This prevents a situation where goroutines can be created faster than they can be completed, leading to OOM. --- bitswap/client/client.go | 4 ++-- routing/providerquerymanager/providerquerymanager.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bitswap/client/client.go b/bitswap/client/client.go index 2e83949cb..192aac153 100644 --- a/bitswap/client/client.go +++ b/bitswap/client/client.go @@ -109,7 +109,7 @@ func WithoutDuplicatedBlockStats() Option { // lookups. The bitswap default ProviderQueryManager uses these options, which // may be more conservative than the ProviderQueryManager defaults: // -// - WithMaxInProcessRequests(16) +// - WithMaxInProcessRequests(8) // - WithMaxProviders(10) // - WithMaxTimeout(10 *time.Second) // @@ -196,7 +196,7 @@ func New(parent context.Context, network bsnet.BitSwapNetwork, providerFinder Pr if bs.providerFinder != nil && bs.defaultProviderQueryManager { // network can do dialing. pqm, err := rpqm.New(network, bs.providerFinder, - rpqm.WithMaxInProcessRequests(16), + rpqm.WithMaxInProcessRequests(8), rpqm.WithMaxProviders(10), rpqm.WithMaxTimeout(10*time.Second)) if err != nil { diff --git a/routing/providerquerymanager/providerquerymanager.go b/routing/providerquerymanager/providerquerymanager.go index 592f7f814..5564fb892 100644 --- a/routing/providerquerymanager/providerquerymanager.go +++ b/routing/providerquerymanager/providerquerymanager.go @@ -20,7 +20,7 @@ import ( var log = logging.Logger("routing/provqrymgr") const ( - defaultMaxInProcessRequests = 16 + defaultMaxInProcessRequests = 8 defaultMaxProviders = 0 defaultTimeout = 10 * time.Second ) @@ -114,7 +114,7 @@ func WithMaxTimeout(timeout time.Duration) Option { // WithMaxInProcessRequests is the maximum number of requests that can be // processed in parallel. If this is 0, then the number is unlimited. Default -// is defaultMaxInProcessRequests (16). +// is defaultMaxInProcessRequests. func WithMaxInProcessRequests(count int) Option { return func(mgr *ProviderQueryManager) error { mgr.maxInProcessRequests = count