Skip to content

perf(core): refactor mempool, add batch add/remove methods #2540

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

Closed
wants to merge 6 commits into from

Conversation

edg-l
Copy link
Member

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

Motivation

  • Put MempoolTransaction behind an Arc for cheaply cloning
  • Reduce the time some locks are held for
  • Add specialized functions for adding and removing multiple transactions at once. Doing so we avoid multiple requests to hold the lock.
  • Some mempool code used a hashmap get and then remove function, when one can just use remove which returns the removed element, allowing to use it for further logic, simplifying the actual code.

Copy link

github-actions bot commented Apr 23, 2025

Lines of code report

Total lines added: 89
Total lines removed: 1
Total lines changed: 90

Detailed view
+-------------------------------------------------------+-------+------+
| File                                                  | Lines | Diff |
+-------------------------------------------------------+-------+------+
| ethrex/crates/blockchain/blockchain.rs                | 515   | +21  |
+-------------------------------------------------------+-------+------+
| ethrex/crates/blockchain/mempool.rs                   | 615   | +44  |
+-------------------------------------------------------+-------+------+
| ethrex/crates/blockchain/payload.rs                   | 555   | +7   |
+-------------------------------------------------------+-------+------+
| ethrex/crates/common/types/transaction.rs             | 2511  | +7   |
+-------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/connection.rs       | 541   | +6   |
+-------------------------------------------------------+-------+------+
| ethrex/crates/networking/p2p/rlpx/eth/transactions.rs | 312   | -1   |
+-------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/clients/eth/mod.rs       | 996   | +3   |
+-------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/engine/fork_choice.rs    | 394   | +1   |
+-------------------------------------------------------+-------+------+

Copy link

github-actions bot commented Apr 23, 2025

Benchmark Block Execution Results Comparison Against Main

Command Mean [s] Min [s] Max [s] Relative
base 253.190 ± 2.183 250.661 258.233 1.00 ± 0.02
head 253.184 ± 4.083 249.359 262.135 1.00

@edg-l edg-l changed the title perf(core): refactor mempool a bit perf(core): refactor mempool, add batch add/remove methods Apr 28, 2025
@edg-l edg-l closed this May 21, 2025
@edg-l edg-l deleted the edgl_mempool_rework branch May 21, 2025 12:59
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.

1 participant