Skip to content

Commit

Permalink
reduce default number of routing in-process requests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gammazero committed Jan 17, 2025
1 parent b62b60e commit 74196b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions bitswap/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
//
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions routing/providerquerymanager/providerquerymanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
var log = logging.Logger("routing/provqrymgr")

const (
defaultMaxInProcessRequests = 16
defaultMaxInProcessRequests = 8
defaultMaxProviders = 0
defaultTimeout = 10 * time.Second
)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 74196b9

Please sign in to comment.