bitcoin/bitcoin — pull request #1619 by mikehearn (2012-07-21 18:47:11+00:00)
Title: Use LevelDB by default for the transaction database

This patch set imports the Google LevelDB 1.5 database, refactors the transaction database code a little and then lets you pick between LevelDB or BDB via a build flag (qmake USE_LEVELDB=- to go back).

On test machines, LevelDB seems to be significantly faster than BDB due to the fact that the bulk of the IO work is handled by a separate thread. The main thread just appends data to the end of a log file when writing, and the IO thread then turns logs into sorted tables and compacts them together.

When indexing the block chain Bitcoin appears to be CPU bound on Windows and Linux machines, even during migration when signature checking is disabled. On my SSD based MacBook Pro the performance isn't as good and it still seems to be IO bottlenecked, which is the opposite of what I'd expect.

This code instructs LevelDB to use a 10-bit bloom filter per block. This expands the size of the database quite a bit, but allows a reduction in disk seeks. I haven't tested different bloom filter sizes to see what works better. It is an area for future work.

LevelDB is statically included because:

- Upstream is not widely packaged and the build system does not support "make install", so it's annoying to link against
- We need custom patches to make it work on Windows.
- It's important that all Bitcoin users are running on a db engine tested by us. We don't want some fraction of the network nodes to be "upgraded" but still running on BDB just because of who built their binaries.