Cinder

A hash is not a node: trie references of 36 bytes instead of 208

TL;DR

In the Merkle Patricia trie, a branch node can point to up to 16 children by their hash. When Cinder decoded a branch, each child that was only a hash got a full trie node of 208 bytes. So one branch with 16 children made 17 full nodes, about 3.8 KiB. A profile of 2026-10-22 counted about 109 000 such objects per block in the state root, for about 9 500 decoded nodes. We split the node type. Every node now starts with a common part of 36 bytes (type, flags, hash), and a hash reference is only that part. We ran an interleaved A/B on 1 074 mainnet blocks with release-type builds. A block took 0.923 of the time of the base (95% interval 0.919 to 0.927), 3.7 ms less. The work arena of a block is 37% smaller by mean. The peak memory of the process is 23 to 25% smaller. The change is on main for the next release. It is a desktop replay result, not a live one yet.

Some speed-ups come from a smarter algorithm. This one came from counting objects. On 2026-10-22 we profiled the state root of Cinder on a cold window of mainnet blocks, on one core. One number did not look right: about 109 000 trie node objects per block in the state root, and about 31 500 in execution, for about 9 500 decoded nodes. That is more than ten objects for each decoded node.

This post explains where the extra objects came from, the change we made, the one design that we threw away on the way, and what the change gave on 1 074 mainnet blocks.

Why a trie has children that are only a hash

Ethereum keeps its state in Merkle Patricia tries. A branch node has up to 16 children. In the encoded node, a child is usually not the child itself, but the keccak-256 hash of the child. To compute a new state root, a client decodes the nodes on the paths that changed. It does not need the other children: for them, the hash is all it needs.

So most children of a decoded branch stay what they are in the encoding: a 32-byte hash. A walk that goes down one of them reads that child from the database, decodes it, and replaces the hash with the node.

The cost: 17 full nodes for one branch

In Cinder, every child got the same node type, a full trie node of 208 bytes, with room for a path, a value, an encoding and 16 children. A child that was only a hash used the hash field and left the rest empty. A decoded branch with 16 hash children thus made 17 full nodes: about 3.8 KiB of the arena, measured with alignment. The arena is the per-block work memory of the trie code.

The change: a common part, and a full node around it

A hash reference got the same 208-byte node as a decoded node. Now it gets 36 bytes.

RowBefore (0.9.5)After (#272)
A child that is only a hash (40 bytes in the arena, with alignment)208 bytes36 bytes
Size of the trie node object for a child that is only a reference by hash, in bytes, bars from zero. Record: docs/results/2026-10-compact-hashref.md (2026-10-22).

Two decisions on the way

No free of a single node. A resolved reference stays in the arena until the arena is reset at the end of the block, as all nodes did before. We could have given its memory back at once. We did not. If no single node is ever freed, no pointer can point to freed memory after a reorg or an undo, which is where such bugs like to hide. 36 bytes per reference is a small price for that.

One type with a short block: rejected. The scratch version of the change used one node type and allocated a short block for a reference. It worked, but the sanitizer did not accept it: UBSan (-fsanitize=object-size) reports a short block of a larger type as an access to an object that is too small. The final change has two types, so a reference is a real object of its own size, and a full node is never shorter than its type.

The result on 1 074 mainnet blocks

A block took 0.923 of the time of the base, 3.7 ms less. The A/A control gave 0.999.

RowA: main at 0.9.5B: compact references
Time per block, minimum over 4 rounds (mean of the blocks)48.7 ms45.0 ms
Time per block, mean over 4 rounds57.5 ms53.4 ms
Time per block of decode, witness load, execution and state root, in ms of CPU time, bars from zero. 1 074 mainnet blocks, PGO and ThinLTO builds, one core of a desktop computer with other load, 2026-10-22. Record: docs/results/2026-10-compact-hashref.md.
Time per block A B B/A 95% interval
minimum over 4 rounds 48.71 ms 44.97 ms 0.923 0.919 to 0.927
mean over 4 rounds 57.51 ms 53.37 ms 0.928 0.921 to 0.935
A/A control (A2/A), minimum 0.999 0.994 to 1.004

The A/A ratio of the means is 0.8% from 1. That is the noise of this computer under load. The change is 7.7%, well clear of it. Each of the 4 rounds alone gave B/A 0.921 to 0.933.

The work memory of a block is 37% smaller by the mean of the blocks. The peak memory of the process is 0.75 to 0.77 of the base.

RowA: main at 0.9.5B: compact references
Work arena at the end of a block, mean of blocks57.8 MB36.3 MB
Work arena at the end of a block, largest block132.5 MB73.2 MB
The trie work arena at the end of each block, in MB, bars from zero. 1 074 mainnet blocks, the same runs as the time chart, 2026-10-22. Record: docs/results/2026-10-compact-hashref.md.
Memory A B B/A
work arena at the end of a block, mean of blocks 57.8 MB 36.3 MB 0.627
work arena at the end of a block, largest block 132.5 MB 73.2 MB 0.552
peak RSS of a process of 12 blocks, mean of groups 177.8 MiB 137.2 MiB 0.772
peak RSS of a process of 12 blocks, largest group 212.3 MiB 159.5 MiB 0.751

A note on the peak memory, because two numbers are around. By the mean of the groups, the peak memory is 0.772 of the base: 23% less. On the largest group it is 0.751: 25% less. The changelog gives 25%. Both ratios are in the record, and the table gives both.

How we checked that the roots did not change

A change to trie nodes must not change one byte of a state root. The checks:

An independent review then read the change with the assertions turned on in a release build, and found nothing.

What this does not show

Updated 2026-10-24: we measured it. Two versions did not make a block faster, and we rejected the change. The data is in An estimate of 3.9% and a result in the noise.

The internals pages describe the state root and the trie. To run Cinder on your own blocks, ask for access at getcinder.dev/access.