原始文献 / 论坛帖 / Faster initial block download (5x faster)
Faster initial block download (5x faster)
Bitcointalk · 2010-07-23 18:24:56 UTC
通过调整数据库设置,我把初始区块下载提速了约 5 倍。现在大约 30 分钟就能下载完。
数据库默认是每个区块同步写入磁盘,这没必要。我改成让它在内存里缓存改动、批量写出。区块仍然是事务性写入的,所以要么完整变更生效、要么完全不生效,两种情况下数据都保持有效状态。
我只在初始区块下载期间启用这个改动。当你离最新区块不到 2000 个区块时,这些改动会关闭,变回原来的慢速方式。
我做了个测试构建版,如果你想用可以开始用了:
http://www.bitcoin.org/download/bitcoin-0.3.2.5-win32.zip
http://www.bitcoin.org/download/bitcoin-0.3.2.5-linux.tar.gz
这些二进制文件还包含了 Gavin Andresen 的 JSON-RPC HTTP 认证功能和 0.3.2 的其他重要安全改进。
过去 24 小时我一直在跑一个测试,每 2-60 秒随机杀掉重启它(可怜的家伙),当时它正在做初始区块下载,一直都没问题。
钱包 wallet.dat 的处理方式没有任何改动。这个改动只针对 blk*.dat 和不重要的 addr.dat。blk*.dat 坏了你随时可以删掉让它重下。
英文原文
By making some adjustments to the database settings, I was able to make the initial block download about 5 times faster. It downloads in about 30 minutes.
The database default had it writing each block to disk synchronously, which is not necessary. I changed the settings to let it cache the changes in memory and write them out in a batch. Blocks are still written transactionally, so either the complete change occurs or none of it does, in either case the data is left in a valid state.
I only enabled this change during the initial block download. When you come within 2000 blocks of the latest block, these changes turn off and it slows down to the old way.
I built a test build if you'd like to start using it:
http://www.bitcoin.org/download/bitcoin-0.3.2.5-win32.zip
http://www.bitcoin.org/download/bitcoin-0.3.2.5-linux.tar.gz
These binaries also include Gavin Andresen's JSON-RPC HTTP authentication feature and the other important security improvements from 0.3.2.
I've been running a test over the last 24 hours that kills and restarts it randomly every 2-60 seconds (poor thing) while it's trying to do an initial block download and it's been fine.
There are no changes to the way it handles wallet.dat. This change is only for blk*.dat and the non-critical addr.dat. You can always delete blk*.dat if it gets screwed up and let it re-download.
