Skip to content

Commit

Permalink
feat: add flags to configure bitswap tuning params (#203)
Browse files Browse the repository at this point in the history
* feat: allow configuration of bitswap/routing tuning params.

New CLI flags:

- `routing-max-requests` - Maximum number of concurrent find requests
- `routing-max-providers` - Maximum number of providers to return for each find request
- `routing-max-timeout` - Maximum time for to find the maximum number of providers

Corresponding environ vars:

`ROUTING_MAX_REQUESTS`
`ROUTING_MAX_PROVIDERS`
`ROUTING_MAX_TIMEOUT`
  • Loading branch information
gammazero authored Dec 3, 2024
1 parent 10cd50a commit f3dcc26
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ The following emojis are used to highlight certain changes:
### Added

- Added endpoints to show and purge connected peers [#194](https://github.com/ipfs/rainbow/pull/194)
- Added flags to configure bitswap/routing tuning params:
- `routing-max-requests`
- `routing-max-providers`
- `routing-max-timeout`

### Changed

Expand Down
23 changes: 23 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,24 @@ Generate an identity seed and launch a gateway:
EnvVars: []string{"PEBBLE_WAL_MIN_SYNC_INTERVAL"},
Usage: "Sets the minimum duration between syncs of the WAL",
},
&cli.IntFlag{
Name: "routing-max-requests",
Value: 16,
EnvVars: []string{"ROUTING_MAX_REQUESTS"},
Usage: "Maximum number of concurrent provider find requests, 0 for unlimited",
},
&cli.IntFlag{
Name: "routing-max-providers",
EnvVars: []string{"ROUTING_MAX_PROVIDERS"},
Value: 0,
Usage: "Maximum number of providers to return for each provider find request, 0 for unlimited",
},
&cli.DurationFlag{
Name: "routing-max-timeout",
Value: 10 * time.Second,
EnvVars: []string{"ROUTING_MAX_TIMEOUT"},
Usage: "Maximum time for routing to find the maximum number of providers",
},
}

app.Commands = []*cli.Command{
Expand Down Expand Up @@ -540,6 +558,11 @@ share the same seed as long as the indexes are different.
WALBytesPerSync: cctx.Int("pebble-wal-Bytes-per-sync"),
MaxConcurrentCompactions: cctx.Int("pebble-max-concurrent-compactions"),
WALMinSyncInterval: time.Second * time.Duration(cctx.Int("pebble-wal-min-sync-interval-sec")),

// Routing ProviderQueryManager config
RoutingMaxRequests: cctx.Int("routing-max-requests"),
RoutingMaxProviders: cctx.Int("routing-max-providers"),
RoutingMaxTimeout: cctx.Duration("routing-max-timeout"),
}
var gnd *Node

Expand Down
5 changes: 5 additions & 0 deletions setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ type Config struct {
WALBytesPerSync int
MaxConcurrentCompactions int
WALMinSyncInterval time.Duration

// ProviderQueryManager configuration.
RoutingMaxRequests int
RoutingMaxProviders int
RoutingMaxTimeout time.Duration
}

func SetupNoLibp2p(ctx context.Context, cfg Config, dnsCache *cachedDNS) (*Node, error) {
Expand Down
6 changes: 5 additions & 1 deletion setup_bitswap.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ func setupBitswapExchange(ctx context.Context, cfg Config, h host.Host, cr routi

// Custom query manager with the content router and the host
// and our custom options to overwrite the default.
pqm, err := providerquerymanager.New(ctx, h, cr, providerquerymanager.WithMaxInProcessRequests(100))
pqm, err := providerquerymanager.New(ctx, h, cr,
providerquerymanager.WithMaxInProcessRequests(cfg.RoutingMaxRequests),
providerquerymanager.WithMaxProviders(cfg.RoutingMaxProviders),
providerquerymanager.WithMaxTimeout(cfg.RoutingMaxTimeout),
)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit f3dcc26

Please sign in to comment.