Skip to content

perf(l1): reduce transaction clone and Vec grow overhead in mempool #2637

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

edg-l
Copy link
Member

@edg-l edg-l commented Apr 29, 2025

Motivation

Improve perfomance

Description

Reduces transaction clone overhead on the mempool and Vec initial grow overhead.

The main focus on this pr was the mempool fetch transaction method whose overhead before was 15%, reducing it to 13%, whose main time is spent in the filter transaction method, which had a clone taking 5% of the time now reduced to non existent levels using an Arc.

Images of the perf profile:

Before

image

After

image

Closes #issue_number

@edg-l edg-l requested a review from a team as a code owner April 29, 2025 09:29
Copy link

Lines of code report

Total lines added: 1
Total lines removed: 1
Total lines changed: 2

Detailed view
+-------------------------------------------+-------+------+
| File                                      | Lines | Diff |
+-------------------------------------------+-------+------+
| ethrex/crates/blockchain/mempool.rs       | 572   | +1   |
+-------------------------------------------+-------+------+
| ethrex/crates/common/types/transaction.rs | 2503  | -1   |
+-------------------------------------------+-------+------+

@edg-l
Copy link
Member Author

edg-l commented Apr 30, 2025

some local bench load tests

Specs:
CPU: AMD Ryzen 9 7900X3D (24 threads) @ 5.66 GHz (native march = AVX512)
RAM: 64gb @ 6000mt/s

Commands

# first terminal
cargo run --bin ethrex --release --features dev -- --network test_data/genesis-l1-dev.json --dev
# second terminal
make load-test

main (33e34ef)
First 3 saturated blocks (ggas/s): 0.27, 0.27,0.24
Last 3 saturated blocks (ggas/s):0.17,0.16,0.17,0
Total 209 seconds

PR #2637 (9eb253e)
First 3 saturated blocks saturados (ggas/s): 0.27, 0.26, 0.26
Last 3 saturated blocks (ggas/s): 0.16, 0.17, 0.17
Total: 203 seconds

Copy link

github-actions bot commented Apr 30, 2025

Benchmark Block Execution Results Comparison Against Main

Command Mean [s] Min [s] Max [s] Relative
base 219.945 ± 1.267 218.703 223.071 1.00 ± 0.01
head 219.899 ± 1.110 218.066 221.707 1.00

@edg-l
Copy link
Member Author

edg-l commented Apr 30, 2025

Using load-test-erc20

main: Load test finished. Elapsed time: 433 seconds main
PR: Load test finished. Elapsed time: 428 seconds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants