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): reusing FindNode message per lookup loop (#5047)
**Motivation**
Noticed that random key creation for FindNode messages was consuming a
lot of CPU:
<img width="1860" height="563" alt="image"
src="https://github.com/user-attachments/assets/9d823161-6013-41fe-94b1-008803edb353"
/>
**Description**
So, instead of creating a new key on each message, we create a FindNode
message on every lookup cycle, and encode it a single time to send to
all peers. It removes some randomness but gains in performance. In any
case, next lookup cycle will create a new key.
New flamegraph:
<img width="1854" height="539" alt="image"
src="https://github.com/user-attachments/assets/d2b42609-e178-4ec7-a1a7-31230926c06e"
/>
Tested on mainnet to see if it reduced peer finding performance, and it
took 3' 24'' to find 50 peers
```
2025-10-24T18:48:42.213697Z INFO ethrex_p2p::network: P2P Snap Sync:
elapsed: 00h 03m 23s 00ms
50 peers.
Current step: Downloading Headers
```
and 13' 43'' to reach the 100 peers limit:
```
2025-10-24T18:59:02.280007Z INFO ethrex_p2p::network: P2P Snap Sync:
elapsed: 00h 13m 43s 00ms
100 peers.
Current step: Downloading Headers
```
---------
Co-authored-by: Edgar <[email protected]>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,10 @@
2
2
3
3
## Perf
4
4
5
+
### 2025-10-27
6
+
7
+
- Reusing FindNode message per lookup loop instead of randomizing the key for each message. [#5047](https://github.com/lambdaclass/ethrex/pull/5047)
8
+
5
9
### 2025-10-21
6
10
7
11
- Instead of lazy computation of blocklist, do greedy computation of allowlist and store the result, fetch it with the DB. [#4961](https://github.com/lambdaclass/ethrex/pull/4961)
0 commit comments