Skip to content
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

[WIP] perf: remove TrieUpdates::removed_nodes and StorageTrieUpdates::removed_nodes (attempt 2) #13929

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kien-rise
Copy link
Contributor

@kien-rise kien-rise commented Jan 22, 2025

Replaces #13872. This PR is only slightly worse than as good as #13872, but the code changes are minimal.

Checklist

  • E2E Benchmark
  • Add benches/*
  • Improve PR description

Motivation

Under high load (TPS > 50,000), MemoryOverlayStateProviderRef::trie_state is taking a considerable amount of time (over 200ms). One factor contributing to this is the TrieUpdates::extend_ref function. Optimizing the struct definition of TrieUpdates could help improve the performance of the extend_ref function.

Notable changes

pub struct TrieUpdates {
-    pub account_nodes: HashMap<Nibbles, BranchNodeCompact>,
-    pub removed_nodes: HashSet<Nibbles>,
+    pub changed_nodes: HashMap<Nibbles, Option<BranchNodeCompact>>,
     pub storage_tries: B256HashMap<StorageTrieUpdates>,
 }

pub struct StorageTrieUpdates {
     pub is_deleted: bool,
-    pub storage_nodes: HashMap<Nibbles, BranchNodeCompact>,
-    pub removed_nodes: HashSet<Nibbles>,
+    pub changed_nodes: HashMap<Nibbles, Option<BranchNodeCompact>>,
 }
Benchmarks
192.155.101.220/slave/785bc168-9976731c-erc20-30600/realtime-block.stdout.log
{"tps": 30601.0, "gps": 1056921850.8367347, "is_chain_lagged": false, "chain_lag_distance": 0}
192.155.101.220/slave/785bc168-9976731c-erc20-31000/realtime-block.stdout.log
{"tps": 31001.0, "gps": 1070736094.1406412, "is_chain_lagged": false, "chain_lag_distance": 0}
192.155.101.220/slave/785bc168-9976731c-erc20-32000/realtime-block.stdout.log
{"tps": 32001.0, "gps": 1105272921.4311633, "is_chain_lagged": false, "chain_lag_distance": 1}
192.155.101.220/slave/785bc168-9976731c-erc20-33000/realtime-block.stdout.log
{"tps": 33001.0, "gps": 1139812889.5115511, "is_chain_lagged": false, "chain_lag_distance": 1}
192.155.101.220/slave/785bc168-9976731c-erc20-34000/realtime-block.stdout.log
{"tps": 34001.0, "gps": 1174346187.1292517, "is_chain_lagged": true, "chain_lag_distance": 4}
192.155.101.220/slave/785bc168-9976731c-erc20-36000/realtime-block.stdout.log
{"tps": 36001.0, "gps": 1243424508.7788463, "is_chain_lagged": true, "chain_lag_distance": 20}
192.155.101.220/slave/785bc168-9976731c-erc20-40000/realtime-block.stdout.log
{"tps": 40001.0, "gps": 1381586516.224, "is_chain_lagged": true, "chain_lag_distance": 61}
192.155.101.220/slave/785bc168-9976731c-raw-transfer-54600/realtime-block.stdout.log
{"tps": 54601.0, "gps": 1146644512.2513661, "is_chain_lagged": false, "chain_lag_distance": 1}
192.155.101.220/slave/785bc168-9976731c-raw-transfer-55000/realtime-block.stdout.log
{"tps": 55001.0, "gps": 1155044519.4926472, "is_chain_lagged": false, "chain_lag_distance": 0}
192.155.101.220/slave/785bc168-9976731c-raw-transfer-56000/realtime-block.stdout.log
{"tps": 56001.0, "gps": 1176044515.2560747, "is_chain_lagged": false, "chain_lag_distance": 1}
192.155.101.220/slave/785bc168-9976731c-raw-transfer-57000/realtime-block.stdout.log
{"tps": 57001.0, "gps": 1197044511.5361216, "is_chain_lagged": false, "chain_lag_distance": 0}
192.155.101.220/slave/785bc168-9976731c-raw-transfer-58000/realtime-block.stdout.log
{"tps": 58001.0, "gps": 1218044525.3953488, "is_chain_lagged": false, "chain_lag_distance": 1}
192.155.101.220/slave/785bc168-9976731c-uniswap-6330/realtime-block.stdout.log
{"tps": 6331.0, "gps": 882450529.3786408, "is_chain_lagged": false, "chain_lag_distance": 0}
192.155.101.220/slave/785bc168-9976731c-uniswap-6400/realtime-block.stdout.log
{"tps": 6401.0, "gps": 892212483.2733675, "is_chain_lagged": false, "chain_lag_distance": 0}
192.155.101.220/slave/785bc168-9976731c-uniswap-6480/realtime-block.stdout.log
{"tps": 6481.0, "gps": 903368570.772521, "is_chain_lagged": false, "chain_lag_distance": 0}
192.155.101.220/slave/785bc168-9976731c-uniswap-6580/realtime-block.stdout.log
{"tps": 6581.0, "gps": 917296337.1077226, "is_chain_lagged": true, "chain_lag_distance": 4}

@emhane emhane added the C-perf A change motivated by improving speed, memory usage or disk footprint label Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-perf A change motivated by improving speed, memory usage or disk footprint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants