Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perf/smoother peer discovery #5846

Merged
merged 18 commits into from
Jun 23, 2023
Merged

Perf/smoother peer discovery #5846

merged 18 commits into from
Jun 23, 2023

Conversation

asdacap
Copy link
Contributor

@asdacap asdacap commented Jun 21, 2023

  • The way new outgoing connection is spawned tend to be spiky, spawning number of connection in bulk. There are also several wait time in an attempt to not spawn too much connection.
  • This changes that by having a pool of tasks listening to a blocking channel which is feed by the main peer connection loop. In another word, the peer connection loop is blocked if all thread/task is in use, allowing for an early break if active peer is full. No need to estimate how much you need to push to the threads, which results in much higher thread/task utilization.
  • To throttle, an explicit rate limiter is added with a new config --Network.MaxOutgoingConnectPerSec which default to 20, which matches the current peak rate. Unthrottled, peak with 32 thread is about 80 connection per sec.
  • The result is, inconsistent as always. But you can set the limit to 999999 and DOS your router if you want.
Run Time to reach 100 peer (minute)
Before 25
After (10 connect per sec) 25
After (20 connect per sec) 30
Before 40
After (10 connect per sec) 45
After (no limit) 25
After (no limit) 30
After (no limit ) 30

Screenshot from 2023-06-22 09-15-01

Changes

  • List the changes

Types of changes

What types of changes does your code introduce?

  • Optimization

Testing

Requires testing

  • Yes
  • No

If yes, did you write tests?

  • Yes
  • No

@asdacap asdacap force-pushed the perf/smoother-peer-discovery branch from a0a17fe to 9eb9811 Compare June 21, 2023 13:38
@asdacap asdacap marked this pull request as ready for review June 22, 2023 05:54
@asdacap asdacap merged commit 6ab0a3a into master Jun 23, 2023
@asdacap asdacap deleted the perf/smoother-peer-discovery branch June 23, 2023 06:21
MarekM25 pushed a commit that referenced this pull request Jul 3, 2023
* Continuously connect

* Added another delay due to disconnect

* Increase useless peer timeout

* Simple rate limiter

* Integrate with peer manager

* Adjust some stats

* Check all peer, and uses pending variable

* Make logic clearer

* Minor cleanup

* Missed cancellation token

* Cancel setup outgoing peer connection if throttled

* Lockless ratelimiter

* Addressing comment

* Minor adjustments

* Whitespace

* Having trouble getting candidate at higher speed

* Make test more consistent

* Even more lenient

(cherry picked from commit 6ab0a3a)
kamilchodola added a commit that referenced this pull request Aug 1, 2023
* Add missing peer types to limits (#5838)

* Add missing peer types to limits

* Add Reth

* Flaky test

* Use better processing timer for logging (#5843)

* Use different processing timer

* Use single queue

* Revert to simpler

* Add Gnosis Shanghai hard-fork timestamp (#5848)

* Don't use DarkGray (#5849)

* Bump to 1.20.0-rc

* MaxDegreeOfParallelism defaults for full pruning (#5662)

* other defaults for full pruning?

* degreeOfParalleism

* small refactor

* fix build

* Fixing BatchedTrieVistior

* 25% of cores

* Update Pruning config

* add logger

* fix

* Perf/smoother peer discovery (#5846)

* Continuously connect

* Added another delay due to disconnect

* Increase useless peer timeout

* Simple rate limiter

* Integrate with peer manager

* Adjust some stats

* Check all peer, and uses pending variable

* Make logic clearer

* Minor cleanup

* Missed cancellation token

* Cancel setup outgoing peer connection if throttled

* Lockless ratelimiter

* Addressing comment

* Minor adjustments

* Whitespace

* Having trouble getting candidate at higher speed

* Make test more consistent

* Even more lenient

(cherry picked from commit 6ab0a3a)

* Update RocksDB package (#5883)

(cherry picked from commit 4e2bf0f)

* Update DotNetty feed

(cherry picked from commit 3e330ad)

* Update DotNetty package

(cherry picked from commit 47a92ee)

* add more gnosis bootnodes (#5910)

(cherry picked from commit b7086a9)

* Remove `v` of non-legacy tx signature from RPC response (#5927)

* minor fixes

* Update version to 1.20.0

* Bump to 1.20.1

* Restore `v` in tx signature for Geth compatibility (#5937)

* Restore DotNetty feed (#5976)

* Revert `nuget.config`

* Update DotNetty package

---------

Co-authored-by: Ben Adams <thundercat@illyriad.co.uk>
Co-authored-by: Ruben Buniatyan <rubo@users.noreply.github.com>
Co-authored-by: Kamil Chodoła <kamil@nethermind.io>
Co-authored-by: Marek Moraczyński <marekm2504@gmail.com>
Co-authored-by: Amirul Ashraf <asdacap@gmail.com>
Co-authored-by: Marcin Sobczak <marcindsobczak@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants