Cinder

Sync from genesis: 256 blocks per write, 40 times fewer fsync calls, and a prewarm result we could not claim

TL;DR

Cinder 1.0 must sync mainnet from genesis on its own. On 2026-11-05 we measured three speed items of that sync on 3 000 Hoodi blocks. Each arm had 5 runs, with an A/A control in every experiment. Write batches of 256 blocks: the execution stage took 38.0% less time (95% interval 28.1% to 47.9%) and wrote 37.0% fewer pages. Kept. Lazy commits: the fsync calls went from 716 to 18, and the time from 92.2 s to 82.4 s. But the two A/A arms were 8.4% apart, so on this fast disk we cannot claim a time gain. Kept for slower disks, with a limit of 1 GiB. Without the limit, the file grew from 3.9 GB to 21.9 GB in one run. A second write of each stored body: libmdbx writes no page for an equal value, so the fix needed no code. The prewarm off: the mean was 13.8% slower. But one run of 165 s made most of that, and the medians were equal. The prewarm stays on, and we do not claim a number for it. This is work on the development line toward 1.0, not a release.

Cinder 1.0 has to do a thing that 0.9 does not: sync mainnet from genesis, with no help from another client’s database. That is millions of blocks through one execution stage and one database writer. So small costs per block become hours.

On 2026-11-05 we measured three items of the sync plan on real blocks. I write about all three here, because each one ended in a different way: one clear gain, one gain we could not see on this disk, and one fix that needed no code. Then there is the prewarm, where the mean said one thing and the A/A control said “not so fast”.

This is work on the development line toward 1.0. None of it is in a release yet.

Write batches of 256 blocks: kept

The execution stage took 38.0% less time with write batches of 256 blocks, and wrote 37.0% fewer pages.

Before, the execution stage gave the writer at most 64 blocks per write transaction, and it stopped to wait for the writer at 32 unwritten blocks. In the blocks with many new accounts the writer is the limit. A larger batch writes a page that several blocks change only one time.

RowTime of the execution stage, mean of 5 runs
A: 64 blocks per write, 32 ahead100.3 s
A2: the same binary (A/A control)96.6 s
128 blocks per write, 128 ahead70.3 s
256 blocks per write, 256 ahead62.2 s
Wall time of the execution stage over 3 000 Hoodi blocks, seconds, bars from zero. Experiment e2, 5 runs per arm, desktop computer, 2026-11-05. Record: docs/results/2026-11-sync-commits.md.
Arm (e2, 5 runs each) Time, mean Pages per block Time against A (95%) Pages against A (95%)
A: 64 per write, 32 ahead 100.3 s 1 508
A2: the same binary 96.6 s 1 513 -3.7% +0.3%
128 per write, 128 ahead 70.3 s 1 116 -29.9% -26.0%
256 per write, 256 ahead 62.2 s 950 -38.0% (-47.9 to -28.1) -37.0% (-37.4 to -36.7)

The time interval is wide. The A/A arm moved by 3.7% on its own. The page count is the steadier number: libmdbx counts the pages, and the two A arms differ by 0.3%. When the time is noisy and the pages are exact, I trust the pages more, and they say the same thing.

A second experiment split the two limits. It showed that most of the gain comes from the number of blocks that the execution may run ahead of the writer. With 32, a writer batch could not grow past 32 blocks, also when the writer was the slow part.

Arm (e4, 5 runs each) Time, mean Pages per block Peak memory
A: 64 per write, 32 ahead 90.5 s 1 516 4 623 MB
64 per write, 256 ahead 62.8 s 1 062 6 146 MB
256 per write, 256 ahead 59.0 s 993 6 957 MB
512 per write, 512 ahead 49.3 s 896 7 970 MB

So why not 512? It was faster again, but with about 1 GB more memory than 256. And a mainnet block that waits for the writer holds more state changes, body and receipts than a Hoodi block. We have not measured that memory on mainnet blocks. Until we do, the node takes 256. The option --sync-batch N sets a smaller value for a machine with less memory. The follow path at the chain head keeps 64 and 4, because there each block must reach the disk soon after its forkchoice update.

The cost is in the crash case. The blocks that executed and wait for the writer are only in memory. A kill -9 now loses up to 256 of them plus the batch in progress (before: up to 32). The next start executes them again.

Lazy commits: kept, but not for the time on this disk

The fsync calls went from 716 to 18. The time gain was not larger than the A/A spread.

Before, each commit of the sync stages waited for the disk. With the change, libmdbx makes a commit durable only after 2 minutes or 1 GiB of writes, and the node makes the commits durable at the end of each stage.

Rowlibmdbx fsync calls in the execution stage, mean of 5 runs
A: each commit durable716 calls
A2: the same binary774 calls
Lazy, 2 min and 256 MiB56 calls
Lazy, 2 min and 1 GiB (kept)18 calls
Lazy, 2 min only (rejected)2 calls
fsync calls of libmdbx over 3 000 Hoodi blocks. Log axis: each step is 10 times more. Experiment e3, 5 runs per arm, desktop computer, 2026-11-05. Record: docs/results/2026-11-sync-commits.md.
Arm (e3, 5 runs each) Time, mean fsync calls Last page of the file Time against A (95%)
A: durable 92.2 s 716 949 000
A2: durable, the same binary 84.4 s 774 948 000 -8.5% (-14.9 to -2.9)
Lazy, 2 min and 1 GiB 82.4 s 18 1 182 000 -10.7% (-17.1 to -4.4)
Lazy, 2 min and 256 MiB 84.3 s 56 989 000 -8.6%
Lazy, 2 min only 61.9 s 2 5 341 000 -32.9%

Read the A2 row first. It is the same binary as A, and it came out 8.5% faster than A, with an interval that does not touch zero. That is the noise of this desktop on that day, and it is as large as the gain of the lazy arms. Against the mean of A and A2 (88.3 s), the 1 GiB arm is 6.7% faster. The two A arms are 8.4% apart. On this fast disk, we cannot claim a time gain.

We kept the change for another reason. One fsync on a slower SATA disk costs milliseconds, and the stages make one commit for each write batch. That measurement is not done yet. It is on the plan.

The last row is the interesting one. Without a byte limit, the run was 32.9% faster, and the file grew from 3.9 GB to 21.9 GB in one run of 3 000 blocks. libmdbx reuses the pages that a commit frees only after a durable commit. So with few durable commits, it took new pages at the end of the file and did not search its free list. That speed is real, and it is useless: a sync of the full chain would fill the disk. The limit of 1 GiB costs about 1 GiB of file growth and still gives 40 times fewer fsync calls.

A lazy commit needs proof that a crash is safe. The tests kill the stages with kill -9, and also roll the database back to its last durable commit, as libmdbx does after a power loss. Then they sync on to the target. The head and a hash over all state rows must equal those of a run without the crash. Before the change, the power loss tests fail for a simple reason: no commit is lost, because each commit is durable. The engine answers SYNCING while the stages run, so no answer to the consensus client depends on a lazy commit.

A second write of each body: no code needed

The plan said that the execution stage writes each body again after the bodies stage stored it, and it estimated 600 GB of writes over a mainnet sync. We checked before we built a fix.

libmdbx compares a new value with the stored value before it changes a page. An equal value writes no page. On the Hoodi range, 3 000 of 3 000 bodies were equal to the stored bytes. An arm that skipped the body write wrote -0.3% pages (95% interval -0.6 to +0.2): the same. A test in the database suite now holds this, and it fails if a later libmdbx writes the pages again. The best fix is the one that you find is already there.

The prewarm: a mean we could not claim

Without the prewarm, the writer wrote 8.4% more pages (95% interval +7.7 to +9.1). The time we could not resolve.

The prewarm reads the state that a block will touch before the block runs. The mean time with the prewarm off was 113.4 s, +13.8% against A. It would be easy to write “the prewarm makes the sync 14% faster”. The data do not support that sentence:

The A/A control is the reason I can say this with some confidence. In the three experiments, the two copies of the same binary were 8.0%, 3.7% and 8.5% apart. A difference of 13.8% on a mean of 5 runs, with one outlier, is inside what this machine does to itself. The page count is exact, and it says the prewarm helps the writer. So the prewarm stays on. The option --sync-no-prewarm turns it off for a test on another machine, and the time question stays open.

A larger cache got the same treatment: --cache-mb 8192 gave +7.1% time (95% interval -10.7 to +26.3). On this range the whole database fits in the page cache, so a larger cache saves only a copy. The default of 1 024 MB stays.

The three together

One run of the merged branch, lazy commits and batches of 256 together, took 66.9 s, against 91.4 s for the mean of the 10 A runs. It made 10 fsync calls in the execution stage, against 721, and wrote 965 pages per block, against 1 513. Its peak memory was 8 244 MB. One run gives no interval, so I give these as a check that the parts add up, not as a result.

What this does not show

The plan for 1.0 is on the roadmap. The method of our A/A controls is on How we measure.