mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-14 10:51:35 +00:00
Replace the BinaryNode interface (which uses Go interface pointers that the GC must scan) with NodeRef uint32 indices into typed arena pools. NodeRef packs a 2-bit kind tag and 30-bit pool index into a single uint32, making it invisible to the garbage collector. NodeStore manages chunked typed pools per node kind: - InternalNode pool: ZERO Go pointers (children are NodeRef, hash is [32]byte) → allocated in noscan spans, GC skips entirely - HashedNode pool: ZERO Go pointers → noscan spans - StemNode pool: ONE pointer per node (valueData []byte) → minimal GC For a trie with 25K InternalNodes, this reduces GC-scanned pointer-words from ~125K to ~10K (85% reduction). CPU profiling showed 44% of time in GC; this refactor directly addresses that bottleneck. Serialization format is unchanged — the on-disk representation is fully compatible. All existing tests pass. |
||
|---|---|---|
| .. | ||
| 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 | ||