Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds some jitter to our initial reconnection to our persistent peers. Currently we will attempt reconnections to all peers simultaneously, which results in large amount of contention as the number of channels a node has grows. We resolve this by adding a randomized delay between 0 and 30 seconds for all persistent peers. This spreads out the load and contention to resources such as the database, read/write pools, and memory allocations. On my node, this allows to start up with about 80% of the memory burst compared to the all-at-once approach. This also has a second-order effect in better distributing messages sent at constant intervals, such as pings. This reduces the concurrent jobs submitted to the read and write pools at any given time, resulting in better reuse of read/write buffers and fewer bursty allocation and garbage collection cycles. The behavior can be disabled using the --stagger-initial-reconnect configuration argument. This is useful on mobile devices that want to reconnect to peers as quickly as possible, and also won't have as many channels as lnd nodes run as a daemon. It is also useful for integration tests to ensure that peers reconnect quickly and the test length isn't increased unnecessarily.
- Loading branch information
1 parent
9e8fc90
commit e89aec9
Showing
3 changed files
with
30 additions
and
1 deletion.
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
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
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