Does running pruning node make the initial sync faster?

4

Does running bitcoind with -prune option make the initial blockchain sync faster or not? I know it makes it smaller on disk, but is it faster?

I keep reading conflicting information online - some state that it is quicker because you need less disk operations, some state it is about the same.

Karel Bílek

Posted 2018-09-26T03:31:27.283

Reputation: 2 197

Answers

11

No, pruning will not make the initial sync faster. The information that gets removed by pruning isn't accessed turning the initial sync.

Currently pruning makes the initial sync somewhat slower: more frequent flushes are performed in order to allow pruning to work, and the work of actually deleting things creates its own small slowdown. About the same is probably a fair statement in general.

The only configuration which can substantially speed up the initial sync is increasing the dbcache option. If you have plenty of memory (e.g. >4GB) making this setting larger can radically reduce the sync time, esp. if your disk is slow. For 8GB ram I recommend setting dbcache=4096 during the initial sync.

G. Maxwell

Posted 2018-09-26T03:31:27.283

Reputation: 6 039

2Great tip on the dbcache flagJBaczuk 2018-09-27T04:53:15.063

3

Does running bitcoind with -prune option make the initial blockchain sync faster or not?

No, it just allows you to define the maximum storage space for old blocks to use, but it will still download all of the blocks to verify them, deleting them afterwards.

-prune=<n>
     Reduce storage requirements by enabling pruning (deleting) of old
     blocks. This allows the pruneblockchain RPC to be called to
     delete specific blocks, and enables automatic pruning of old
     blocks if a target size in MiB is provided. This mode is
     incompatible with -txindex and -rescan. Warning: Reverting this
     setting requires re-downloading the entire blockchain. (default:
     0 = disable pruning blocks, 1 = allow manual pruning via RPC,
     >=550 = automatically prune block files to stay under the
     specified target size in MiB)

To reduce the sync time you could use the -assumevalid flag to move the default assumed valid block to a later block, but obviously this is a risk you take.

-assumevalid=<hex>
       If this block is in the chain assume that it and its ancestors are valid
       and potentially skip their script verification (0 to verify all,
       default:
       0000000000000000005214481d2d96f898e3d5416e43359c145944a909d242e0,
       testnet:
       0000000002e9e7b00e1f6dc5123a04aad68dd0f0968d8c7aa45f6640795c37b1)

JBaczuk

Posted 2018-09-26T03:31:27.283

Reputation: 6 172

1Moving assume valid to an earlier block will make the sync slower, not faster. Unless you are running a really old version it's unlikely that you can speed things up substantially by changing it at all.G. Maxwell 2018-09-26T23:49:21.900

0

Pruning won't make your initial sync faster.

I know how painful for an HDD user to sync a full node...

If you have SSD, just use it. You may configure the blocksdir parameter to migrate the gigantic block storage to inexpensive HDD.

There is also an ugly trick to significantly acclerate the initial sync: use RAMDisk/tmpfs to store the chainstate subdirectory. In some more detail, NTFS junction(Windows)/symbolic link(Linux or Mac) could be used to redirect the path, while ImDisk(Windows)/tmpfs(Linux/Mac) could provide the RAMDisk.

A trick which is less ugly also exists: use type(Windows CMD)/cat(Linux/Mac) command to read all files in chainstate subdirectory before starting the full node, so that the OS would load these files into cache. This trick is more useful when you are catching up from several days ago.

Chris Chen

Posted 2018-09-26T03:31:27.283

Reputation: 458

1It's much better to increase your dbcache than to use a RAM disk.Pieter Wuille 2019-01-14T20:38:45.950

But HDDs are incredibly slow. It's so slow that the user may be willing to accept the downsides of a RAMDisk. Despite whether RAMDisk could help the initial sync more than larger dbcache, an ugly manual "preheat" in deed helps the full node to catch up.Chris Chen 2019-01-14T20:47:28.390

1You miss my point. If you make the database cache large enough, the node won't need any disk I/O for validation. That's more efficient than using a RAMdrive to accomplish the same thing.Pieter Wuille 2019-01-14T21:37:49.810

How much RAM is required for this goal? Is 4GB enough? I've seen people accomplish this goal with a RAMDisk of 4GB.Chris Chen 2019-01-14T22:12:29.537

@PieterWuille I once monitored bitcoin-qt.exe with procexp. It turned out that setting dbcache to 4GB is not enought, since I/O operations were continuously emitted after the cache became full.Chris Chen 2019-01-22T23:22:29.880

Yes, you need around 6GB I believe to avoid flushing entirely. But with 4GB it should already be pretty rare.Pieter Wuille 2019-01-23T01:21:11.107

@PieterWuille Although chainstate was not frequently written with 4GB dbcache, resource monitor showed that bitcoin-qt.exe was still intensively emitting random read operations on chainstate.Chris Chen 2019-01-23T01:58:28.190