mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-14 10:51:35 +00:00
Deep branch used a pooled hash.Hash: h.Write(lh[:]) passed a subslice through the interface, forcing lh/rh to heap; h.Sum(nil) allocated 32 B per rehash; empty children allocated 32 B via make([]byte, HashSize). Mirror the shallow branch: write left/right hashes into a stack [64]byte via copy() and call sha256.Sum256 in one shot. No interface writes, no pool round-trip, no Sum(nil), no empty-child make. Benchmark delta (M4 Pro, go1.24.0, --count=5 --benchtime=5s): before: 9133 ns/op 6526 B/op 95 allocs/op after: 8783 ns/op 5623 B/op 67 allocs/op vs upstream/master@53ff723cc: allocs/op -50.0% (was -29.1%), bytes/op -85.1% (was -82.7%), time/op +18.7% (was +23.4%). |
||
|---|---|---|
| .. | ||
| binary_node.go | ||
| binary_node_test.go | ||
| hashed_node.go | ||
| hashed_node_test.go | ||
| hasher.go | ||
| internal_node.go | ||
| internal_node_test.go | ||
| iterator.go | ||
| iterator_test.go | ||
| key_encoding.go | ||
| node_ref.go | ||
| node_store.go | ||
| stem_node.go | ||
| stem_node_test.go | ||
| store_commit.go | ||
| store_ops.go | ||
| trie.go | ||
| trie_test.go | ||