go-ethereum/trie
Marius van der Wijden ddeea1e0c6
core: types: less allocations when hashing and tx handling (#21265)
* core, crypto: various allocation savings regarding tx handling

* core: reduce allocs for gas price comparison

This change reduces the allocations needed for comparing different transactions to each other.
A call to `tx.GasPrice()` copies the gas price as it has to be safe against modifications and
also needs to be threadsafe. For comparing and ordering different transactions we don't need
these guarantees

* core: added tx.GasPriceIntCmp for comparison without allocation

adds a method to remove unneeded allocation in comparison to tx.gasPrice

* core/types: pool legacykeccak256 objects in rlpHash

rlpHash is by far the most used function in core that allocates a legacyKeccak256 object on each call.
Since it is so widely used it makes sense to add pooling here so we relieve the GC.
On my machine these changes result in > 100 MILLION less allocations and > 30 GB less allocated memory.

* reverted some changes

* reverted some changes

* trie: use crypto.KeccakState instead of replicating code

Co-authored-by: Martin Holst Swende <martin@swende.se>
2020-06-30 11:59:06 +02:00
..
committer.go core: types: less allocations when hashing and tx handling (#21265) 2020-06-30 11:59:06 +02:00
database_test.go trie: there's no point in retrieving the metaroot 2019-04-05 13:09:28 +03:00
database.go trie: reduce allocs in insertPreimage (#21261) 2020-06-24 21:56:27 +02:00
encoding_test.go trie: rework and document key encoding 2017-04-25 02:14:31 +02:00
encoding.go trie: fix error in node decoding (#19111) 2019-02-16 16:16:12 +01:00
errors.go trie: more node iterator improvements (#14615) 2017-06-20 18:26:09 +02:00
hasher.go core: types: less allocations when hashing and tx handling (#21265) 2020-06-30 11:59:06 +02:00
iterator_test.go all: simplify and fix database iteration with prefix/start (#20808) 2020-04-15 14:08:53 +03:00
iterator.go trie: make hasher parallel when number of changes are large (#20488) 2020-02-04 14:02:38 +02:00
node_test.go add node.go unit test file node_test.go (#20028) 2020-01-07 10:31:20 +01:00
node.go cmd, core, eth, trie: get rid of trie cache generations (#19262) 2019-03-14 15:25:12 +02:00
proof_test.go trie: enforce monotonic range in prover and return end marker (#21130) 2020-05-27 17:37:37 +03:00
proof.go trie: enforce monotonic range in prover and return end marker (#21130) 2020-05-27 17:37:37 +03:00
secure_trie_test.go cmd, core, eth, trie: get rid of trie cache generations (#19262) 2019-03-14 15:25:12 +02:00
secure_trie.go trie: make hasher parallel when number of changes are large (#20488) 2020-02-04 14:02:38 +02:00
sync_bloom.go all: simplify and fix database iteration with prefix/start (#20808) 2020-04-15 14:08:53 +03:00
sync_test.go trie: remove node ordering slice in sync batch (#19929) 2019-10-28 18:50:11 +01:00
sync.go eth/downloader: minor typo fixes in comments (#21035) 2020-05-06 15:35:04 +02:00
trie_test.go * trie: utilize callbacks instead of amassing lists in ref/unref (#20529) 2020-01-17 13:59:45 +02:00
trie.go trie: make hasher parallel when number of changes are large (#20488) 2020-02-04 14:02:38 +02:00