Skip to content

Conversation

@edg-l
Copy link
Contributor

@edg-l edg-l commented Nov 14, 2025

Motivation

  • In the current impl_encode there are 2 loops to get the position, fixed to a single pass.
  • Added specialized branchless length methods to integers,
  • Added specialized length to Vec
  • Added specialized length to tuples
  • Added specialized length to most types in ethrex-common, only ones missing are in networking/p2p
  • Removed unneeded arrayvec usage
  • Many instances that deref to &[u8] didn't use its length specialized method, fixed to use it

Each missing length impl in the trait impl meant an extra allocation, this should remove them entirely when encoding

Helps with #4956

@github-actions github-actions bot added L1 Ethereum client performance Block execution throughput and performance in general labels Nov 14, 2025
@github-actions
Copy link

github-actions bot commented Nov 14, 2025

Lines of code report

Total lines added: 255
Total lines removed: 0
Total lines changed: 255

Detailed view
+------------------------------------+-------+------+
| File                               | Lines | Diff |
+------------------------------------+-------+------+
| ethrex/crates/common/rlp/encode.rs | 781   | +255 |
+------------------------------------+-------+------+

@edg-l edg-l marked this pull request as ready for review November 14, 2025 12:41
@edg-l edg-l requested a review from a team as a code owner November 14, 2025 12:41
@edg-l edg-l moved this from Todo to In review in ethrex_performance Nov 14, 2025
@edg-l edg-l moved this to In Review in ethrex_l1 Nov 14, 2025
@github-actions
Copy link

github-actions bot commented Nov 14, 2025

Benchmark Block Execution Results Comparison Against Main

Command Mean [s] Min [s] Max [s] Relative
base 60.219 ± 0.158 60.015 60.503 1.00
head 60.581 ± 0.105 60.422 60.752 1.01 ± 0.00

@github-actions
Copy link

Benchmark for ad3c222

Click to view benchmark
Test Base PR %
Trie/cita-trie insert 10k 31.5±2.44ms 31.8±2.65ms +0.95%
Trie/cita-trie insert 1k 2.9±0.02ms 2.9±0.15ms 0.00%
Trie/ethrex-trie insert 10k 27.1±1.61ms 27.7±1.50ms +2.21%
Trie/ethrex-trie insert 1k 2.2±0.04ms 2.2±0.01ms 0.00%

@github-actions
Copy link

Benchmark for 4ad8835

Click to view benchmark
Test Base PR %
Trie/cita-trie insert 10k 31.3±1.45ms 35.9±2.24ms +14.70%
Trie/cita-trie insert 1k 2.9±0.05ms 2.9±0.12ms 0.00%
Trie/ethrex-trie insert 10k 26.6±1.10ms 28.4±0.85ms +6.77%
Trie/ethrex-trie insert 1k 2.2±0.01ms 2.2±0.01ms 0.00%

@github-actions
Copy link

Benchmark for c43b4ff

Click to view benchmark
Test Base PR %
Trie/cita-trie insert 10k 28.8±1.38ms 29.2±1.69ms +1.39%
Trie/cita-trie insert 1k 2.9±0.05ms 2.9±0.13ms 0.00%
Trie/ethrex-trie insert 10k 25.1±1.26ms 25.2±0.90ms +0.40%
Trie/ethrex-trie insert 1k 2.2±0.01ms 2.2±0.03ms 0.00%

edg-l and others added 6 commits November 20, 2025 11:06
Co-authored-by: Tomás Grüner <47506558+MegaRedHand@users.noreply.github.com>
Co-authored-by: Tomás Grüner <47506558+MegaRedHand@users.noreply.github.com>
Copy link
Contributor

@Oppen Oppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Wait until benchmarks for merging.

@edg-l
Copy link
Contributor Author

edg-l commented Nov 27, 2025

rlp benchmarks show an improvement in perf apparently

@edg-l edg-l force-pushed the rlp_improve_encode branch from b6949c5 to 661ec33 Compare November 27, 2025 12:50
@edg-l edg-l added this pull request to the merge queue Nov 27, 2025
Merged via the queue into main with commit 3e4d1e8 Nov 27, 2025
43 checks passed
@edg-l edg-l deleted the rlp_improve_encode branch November 27, 2025 15:16
@github-project-automation github-project-automation bot moved this from In review to Done in ethrex_performance Nov 27, 2025
@github-project-automation github-project-automation bot moved this from In Review to Done in ethrex_l1 Nov 27, 2025
github-merge-queue bot pushed a commit that referenced this pull request Nov 28, 2025
… to calc rlp length (#5374)

**Motivation**

Followup on  #5350 since its already a big pr.

Changed:
- Replaced encode_to_vec().len() calls with length()
- Added more tests

---------

Co-authored-by: Tomás Grüner <47506558+MegaRedHand@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L1 Ethereum client performance Block execution throughput and performance in general

Projects

Status: Done
Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants