-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Conversation
Benchmark shows that almost half the time `apply()`-ing a transaction is spent in garbage collection. This PR avoids visiting each cache item and `collect()`-ing accounts to clean up.
But if there is no perf improvement, what's the point? |
Ah, sorry, now I see it's actually faster, should have looked at the absolute numbers. Test failure is legit though. |
* master: Add benchmark for transaction execution (#11509) Add Smart Contract License v1.0
pub fn kill_garbage(&mut self, touched: &HashSet<Address>, min_balance: &Option<U256>, kill_contracts: bool) -> TrieResult<()> { | ||
let to_kill: HashSet<_> = | ||
touched.iter().filter_map(|address| { // Check all touched accounts | ||
self.cache.borrow().get(address).and_then(|entry| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I collected some more stats on the size of the cache on current mainnet. On the blocks I saw the cache length is invariably higher than size of the touched
collection so I think this change – looping over touched
rather than over the cached items – is good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
touched
is mostly 1, sometimes it goes up to ~10, rarely to ~50. The cache length is between a few tens to a few hundreds.
* master: (27 commits) Faster kill_garbage (#11514) [EngineSigner]: don't sign message with only zeroes (#11524) fix compilation warnings (#11522) [ethcore cleanup]: various unrelated fixes from `#11493` (#11507) Add benchmark for transaction execution (#11509) Add Smart Contract License v1.0 Misc fixes (#11510) [dependencies]: unify `rustc-hex` (#11506) Activate on-chain randomness in POA Sokol (#11505) Grab bag of cleanup (#11504) Implement eth/64 (EIP-2364) and drop support for eth/62 (#11472) [dependencies]: remove `util/macros` (#11501) OpenEthereum bootnodes are added (#11499) [ci benches]: use `all-features` (#11496) [verification]: make test-build compile standalone (#11495) complete null-signatures removal (#11491) Include the seal when populating the header for a new block (#11475) fix compilation warnings (#11492) cargo update -p cmake (#11490) update to published rlp-derive (#11489) ...
* master: Code cleanup in the sync module (#11552) initial cleanup (#11542) Warn if genesis constructor revert (#11550) ethcore: cleanup after #11531 (#11546) license update (#11543) Less cloning when importing blocks (#11531) Github Actions (#11528) Fix Alpine Dockerfile (#11538) Remove AuxiliaryData/AuxiliaryRequest (#11533) [journaldb]: cleanup (#11534) Remove references to parity-ethereum (#11525) Drop IPFS support (#11532) chain-supplier: fix warning reporting for GetNodeData request (#11530) Faster kill_garbage (#11514) [EngineSigner]: don't sign message with only zeroes (#11524)
Profiling the benchmark from #11509 shows that almost half the time
apply()
-ing a transaction is spent in garbage collection. This PR avoids visiting each cache item andcollect()
-ing accounts to clean up.Before this PR: