mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
feat(config): connmgr: expose silence period (#10827)
This commit is contained in:
parent
0cf1b22536
commit
eb6cc02c06
@ -95,6 +95,9 @@ const DefaultConnMgrLowWater = 32
|
||||
// grace period.
|
||||
const DefaultConnMgrGracePeriod = time.Second * 20
|
||||
|
||||
// DefaultConnMgrSilencePeriod controls how often the connection manager enforces the limits.
|
||||
const DefaultConnMgrSilencePeriod = time.Second * 10
|
||||
|
||||
// DefaultConnMgrType is the default value for the connection managers
|
||||
// type.
|
||||
const DefaultConnMgrType = "basic"
|
||||
|
||||
@ -104,10 +104,11 @@ type Transports struct {
|
||||
|
||||
// ConnMgr defines configuration options for the libp2p connection manager.
|
||||
type ConnMgr struct {
|
||||
Type *OptionalString `json:",omitempty"`
|
||||
LowWater *OptionalInteger `json:",omitempty"`
|
||||
HighWater *OptionalInteger `json:",omitempty"`
|
||||
GracePeriod *OptionalDuration `json:",omitempty"`
|
||||
Type *OptionalString `json:",omitempty"`
|
||||
LowWater *OptionalInteger `json:",omitempty"`
|
||||
HighWater *OptionalInteger `json:",omitempty"`
|
||||
GracePeriod *OptionalDuration `json:",omitempty"`
|
||||
SilencePeriod *OptionalDuration `json:",omitempty"`
|
||||
}
|
||||
|
||||
// ResourceMgr defines configuration options for the libp2p Network Resource Manager
|
||||
|
||||
@ -49,7 +49,9 @@ func LibP2P(bcfg *BuildCfg, cfg *config.Config, userResourceOverrides rcmgr.Part
|
||||
grace := cfg.Swarm.ConnMgr.GracePeriod.WithDefault(config.DefaultConnMgrGracePeriod)
|
||||
low := int(cfg.Swarm.ConnMgr.LowWater.WithDefault(config.DefaultConnMgrLowWater))
|
||||
high := int(cfg.Swarm.ConnMgr.HighWater.WithDefault(config.DefaultConnMgrHighWater))
|
||||
connmgr = fx.Provide(libp2p.ConnectionManager(low, high, grace))
|
||||
silence := cfg.Swarm.ConnMgr.SilencePeriod.WithDefault(config.DefaultConnMgrSilencePeriod)
|
||||
connmgr = fx.Provide(libp2p.ConnectionManager(low, high, grace, silence))
|
||||
|
||||
default:
|
||||
return fx.Error(fmt.Errorf("unrecognized Swarm.ConnMgr.Type: %q", connMgrType))
|
||||
}
|
||||
|
||||
@ -25,9 +25,12 @@ type Libp2pOpts struct {
|
||||
Opts []libp2p.Option `group:"libp2p"`
|
||||
}
|
||||
|
||||
func ConnectionManager(low, high int, grace time.Duration) func() (opts Libp2pOpts, err error) {
|
||||
func ConnectionManager(low, high int, grace, silence time.Duration) func() (opts Libp2pOpts, err error) {
|
||||
return func() (opts Libp2pOpts, err error) {
|
||||
cm, err := connmgr.NewConnManager(low, high, connmgr.WithGracePeriod(grace))
|
||||
cm, err := connmgr.NewConnManager(low, high,
|
||||
connmgr.WithGracePeriod(grace),
|
||||
connmgr.WithSilencePeriod(silence),
|
||||
)
|
||||
if err != nil {
|
||||
return opts, err
|
||||
}
|
||||
|
||||
@ -88,6 +88,10 @@ To revert to the previous behavior for A/B testing, set `Internal.Bitswap.Broadc
|
||||
|
||||
The `filestore` command has a new option, `--remove-bad-blocks`, to verify objects in the filestore and remove those that fail verification.
|
||||
|
||||
#### ConnMgr.SilencePeriod configuration setting exposed
|
||||
|
||||
This connection manager option controls how often connections are swept and potentially terminated. See the [ConnMgr documentation](https://github.com/ipfs/kubo/blob/master/docs/config.md#swarmconnmgrsilenceperiod).
|
||||
|
||||
#### 📦️ Important dependency updates
|
||||
|
||||
- update `go-libp2p-kad-dht` to [v0.33.0](https://github.com/libp2p/go-libp2p-kad-dht/releases/tag/v0.33.0)
|
||||
|
||||
@ -171,6 +171,7 @@ config file at runtime.
|
||||
- [`Swarm.ConnMgr.LowWater`](#swarmconnmgrlowwater)
|
||||
- [`Swarm.ConnMgr.HighWater`](#swarmconnmgrhighwater)
|
||||
- [`Swarm.ConnMgr.GracePeriod`](#swarmconnmgrgraceperiod)
|
||||
- [`Swarm.ConnMgr.SilencePeriod`](#swarmconnmgrsilenceperiod)
|
||||
- [`Swarm.ResourceMgr`](#swarmresourcemgr)
|
||||
- [`Swarm.ResourceMgr.Enabled`](#swarmresourcemgrenabled)
|
||||
- [`Swarm.ResourceMgr.MaxMemory`](#swarmresourcemgrmaxmemory)
|
||||
@ -2357,8 +2358,9 @@ Type: `optionalString` (default when unset or empty)
|
||||
|
||||
The basic connection manager uses a "high water", a "low water", and internal
|
||||
scoring to periodically close connections to free up resources. When a node
|
||||
using the basic connection manager reaches `HighWater` idle connections, it will
|
||||
close the least useful ones until it reaches `LowWater` idle connections.
|
||||
using the basic connection manager reaches `HighWater` idle connections, it
|
||||
will close the least useful ones until it reaches `LowWater` idle
|
||||
connections. The process of closing connections happens every `SilencePeriod`.
|
||||
|
||||
The connection manager considers a connection idle if:
|
||||
|
||||
@ -2377,7 +2379,8 @@ The connection manager considers a connection idle if:
|
||||
"Type": "basic",
|
||||
"LowWater": 100,
|
||||
"HighWater": 200,
|
||||
"GracePeriod": "30s"
|
||||
"GracePeriod": "30s",
|
||||
"SilencePeriod": "10s"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2411,6 +2414,14 @@ Default: `"20s"`
|
||||
|
||||
Type: `optionalDuration`
|
||||
|
||||
##### `Swarm.ConnMgr.SilencePeriod`
|
||||
|
||||
SilencePeriod is the time duration between connection manager runs, when connections that are idle are closed.
|
||||
|
||||
Default: `"10s"`
|
||||
|
||||
Type: `optionalDuration`
|
||||
|
||||
### `Swarm.ResourceMgr`
|
||||
|
||||
Learn more about Kubo's usage of libp2p Network Resource Manager
|
||||
|
||||
Loading…
Reference in New Issue
Block a user