Libbitcoin for Core people

This is fixed by validation: write chainstate to disk every hour by andrewtoth · Pull Request #30611 · bitcoin/bitcoin · GitHub.

1 Like

Sure, but that’s cumulative to sync time. It’s not really a fix it just amortizes the cost.

Flush to disk and destruct of an object model is far more costly than flush from mmap. Not only is mmap flush simple but it is paged in the background. Even with 32GB of RAM fully loaded during/after a full sync (with no explicit/periodic flush during sync), flushing the RAM takes around 10 seconds at shutdown.

If not already implemented, it might help Core’s flush time to use a custom linear memory allocator. That effectively eliminates the destruct cost. This can be very high if the objects are passed between threads (another consideration if the cache was to become threadsafe).

1 Like

For example, I just happened to have just completed a full validation run to block 850k.

2024-12-05T19:59:28Z.0 Database stopped successfully in 8 secs.
2024-12-05T19:59:28Z.0 Node stopped successfully.
2024-12-05T19:59:28Z.0 ====================== shutdown ======================
2024-12-05T19:59:28Z.0 Press <enter> to exit...
1 Like

The theoretical limit to download 850k blocks (582,391,632,423 bytes) over 2.3 Gbps Internet is 34 minutes. After integrating shani we are now achieving 40 minutes (plus up to a minute for store build, startup, header sync, and full shutdown) on the $350 benchmark machine.

The remaining 6 minutes is largely a consequence of mmap flushing and remapping the mmap as the files grow. A higher memory machine would eliminate most of that. Also hashing will be further reduced with an avx512 box, which I just ordered for our test bench ($421).

2 Likes

@sjors by the way I went out and bought the exact hardware @evoskuil used for his Windows benchmark (PELADN HA-4, 1TB SSD / 32GB RAM), and I have performed the same benchmark using a slightly newer version of bn.exe .

The sync took 7605 seconds, which is about 127 minutes or 2.11 hours.

My sync was slower than @evoskuil’s because my internet connection is about 800Mbps vs Eric’s >2Gbps.

So libbitcoin does indeed seem to sync very quickly. I should probably do a bitcoin core sync on the same box to set the baseline.

For the record, the hardware cost US$530 for me because of import duties, but 2 hours on a US$530 machine is still an amazing result IMO.

5 Likes