Skip to content

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

Merged
edg-l merged 7 commits into
mainfrom
edgl_mempool_arc
May 13, 2025
Merged

perf(l1): reduce transaction clone and Vec grow overhead in mempool#2637
edg-l merged 7 commits into
mainfrom
edgl_mempool_arc

Conversation

@edg-l

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

Copy link
Copy Markdown
Contributor

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
@github-actions

Copy link
Copy Markdown

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 edg-l added the performance Block execution throughput and performance in general label Apr 30, 2025
@edg-l

edg-l commented Apr 30, 2025

Copy link
Copy Markdown
Contributor Author

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

@github-actions

github-actions Bot commented Apr 30, 2025

Copy link
Copy Markdown

Benchmark Block Execution Results Comparison Against Main

Command Mean [s] Min [s] Max [s] Relative
base 220.318 ± 1.229 218.582 222.315 1.01 ± 0.01
head 218.624 ± 0.902 217.117 219.922 1.00

@edg-l

edg-l commented Apr 30, 2025

Copy link
Copy Markdown
Contributor Author

Using load-test-erc20

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

@edg-l
edg-l added this pull request to the merge queue May 7, 2025
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks May 7, 2025
@edg-l
edg-l added this pull request to the merge queue May 7, 2025
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks May 7, 2025
@edg-l
edg-l enabled auto-merge May 7, 2025 11:37
@edg-l
edg-l added this pull request to the merge queue May 13, 2025
Merged via the queue into main with commit 5d3354f May 13, 2025
@edg-l
edg-l deleted the edgl_mempool_arc branch May 13, 2025 14:33
fmoletta pushed a commit that referenced this pull request May 15, 2025
…2637)

**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](https://github.com/user-attachments/assets/8a2a9e32-8e8d-4c24-8fd2-b5cb91401ee5)

After


![image](https://github.com/user-attachments/assets/1d3a0c56-5826-4efe-874b-8687c230c070)


<!-- A clear and concise general description of the changes this PR
introduces -->

<!-- Link to issues: Resolves #111, Resolves #222 -->

Closes #issue_number
pedrobergamini pushed a commit to pedrobergamini/ethrex that referenced this pull request Aug 24, 2025
…ambdaclass#2637)

**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](https://github.com/user-attachments/assets/8a2a9e32-8e8d-4c24-8fd2-b5cb91401ee5)

After


![image](https://github.com/user-attachments/assets/1d3a0c56-5826-4efe-874b-8687c230c070)


<!-- A clear and concise general description of the changes this PR
introduces -->

<!-- Link to issues: Resolves lambdaclass#111, Resolves lambdaclass#222 -->

Closes #issue_number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Block execution throughput and performance in general

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants