You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf(l1): improved discovery and peer initialization (#5147)
**Motivation**
We are too aggressive on our DiscoveryServer and Initiator. On start we
send up to 5000 Udp messages every 5 seconds and start up to 5000 Tcp
connections every 3 seconds.
After several tests it was found that on one hand it is not necessary to
be that eager, and on the other hand it caused several issues regarding
the tokio runtime (ie. it was blocked for more than 10ms in several
places, causing some problems when trying to synchronize from the local
machine).
**Description**
This PR changes the way Lookup is performed: instead of trying a lot of
connections at the same time every 3 seconds, it distributes the
connection attempts in time, making it more gentle with the CPU. It also
lowers the attempt rate.
- Our Discovery lookup is more frequent, but tries 1 node at a time.
- Our Connection attempt is more frequent, but tries 1 node at a time.
- We match both processes rate to avoid having both, too much pending
connections, or no pending connections at all.
- Also noticed that spawning some GenServers in dedicated threads was no
longer necessary, and it created a lot of threads, as every
`start_on_thread` creates it's own Tokio Runtime with it's thread pool.
- Also removed a spawn_blocking inside a GenServer that may cause a
contention issue.
** Pending (for a future PR) **
- Will create a command line argument to set up the lookup frequency or
eagerness: #5148
- Will make the lookup frequency adjustable at runtime, depending on the
amount of connected peers: #5149
---------
Co-authored-by: Tomás Grüner <[email protected]>
0 commit comments