-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(libp2p): reduce dialer activity in browsers (#1970)
Use a different set of defaults for browsers vs node - from testing we never really see more than 20x connections so there's no point having the auto-dialler trying to reach 50x, also reduce the number of concurrent dials and how many peers we try to autodial at once. This is to reduce overall CPU usage in order to make existing connections more stable.
- Loading branch information
1 parent
e664d14
commit d30f09f
Showing
4 changed files
with
67 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/libp2p/src/connection-manager/constants.browser.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export * from './constants.defaults.js' | ||
|
||
/** | ||
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxParallelDials | ||
*/ | ||
export const MAX_PARALLEL_DIALS = 10 | ||
|
||
/** | ||
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#minConnections | ||
*/ | ||
export const MIN_CONNECTIONS = 5 | ||
|
||
/** | ||
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxConnections | ||
*/ | ||
export const MAX_CONNECTIONS = 100 | ||
|
||
/** | ||
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#autoDialConcurrency | ||
*/ | ||
export const AUTO_DIAL_CONCURRENCY = 10 |
44 changes: 44 additions & 0 deletions
44
packages/libp2p/src/connection-manager/constants.defaults.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#dialTimeout | ||
*/ | ||
export const DIAL_TIMEOUT = 30e3 | ||
|
||
/** | ||
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#inboundUpgradeTimeout | ||
*/ | ||
export const INBOUND_UPGRADE_TIMEOUT = 30e3 | ||
|
||
/** | ||
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxPeerAddrsToDial | ||
*/ | ||
export const MAX_PEER_ADDRS_TO_DIAL = 25 | ||
|
||
/** | ||
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxParallelDialsPerPeer | ||
*/ | ||
export const MAX_PARALLEL_DIALS_PER_PEER = 10 | ||
|
||
/** | ||
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#autoDialInterval | ||
*/ | ||
export const AUTO_DIAL_INTERVAL = 5000 | ||
|
||
/** | ||
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#autoDialPriority | ||
*/ | ||
export const AUTO_DIAL_PRIORITY = 0 | ||
|
||
/** | ||
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#autoDialMaxQueueLength | ||
*/ | ||
export const AUTO_DIAL_MAX_QUEUE_LENGTH = 100 | ||
|
||
/** | ||
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#inboundConnectionThreshold | ||
*/ | ||
export const INBOUND_CONNECTION_THRESHOLD = 5 | ||
|
||
/** | ||
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxIncomingPendingConnections | ||
*/ | ||
export const MAX_INCOMING_PENDING_CONNECTIONS = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters