Bitcointalk · Faster initial block download (5x faster)

中本聪,2010 年 7 月 23 日

SN-1612 已核对来源,附原文与上下文。

阅读语言
中文译文

通过对数据库设置做一些调整,我把初始区块下载提速了约 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 万一坏了,随时可以删掉重新下载。

ORIGINAL · 英文原文
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.
上下文
← 上一条 SN-1612 · 当前 下一条 → 在档案中查看完整主题串 →
来源
Bitcointalk 原始链接 ↗ 记录编号 SN-1612