-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Split BDB database blkindex.dat into multiple databases #1303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
blkmeta.dat contains settings, options and all that stuff, right? |
blkmeta.dat mostly contains random singleton datums like hashBestChain or bnBestInvalidWork |
Updated patch order, dramatically shrinking the diff. |
Breaks Bitcoin-Qt:
|
eca20e7 is the first bad commit |
fixed |
First run, I am prompted to upgrade my database. debug.log fills with lines like this:
Immediately afterward, Bitcoin-Qt crashes:
git bisect blames a commit between aa79af8..jgarzik/blockindex |
|
Fixed in latest commits. |
Commit status notes: Note 1) the base read/write logic works. you can run a peer node stably with this. shut it down, restart, etc. Note 2) there is a strange behavior, where a single record appears during a read-all-records query of a hash database (LoadBlockIndex), which causes CDataStream to throw an error during deserialize. the error output, created by commit 183e670, is
Note 4) On this first pass, the Old Way appears to use significantly less disk space than the New Way: http://pastebin.com/MXRc3WZe It is likely that this can be improved by changing the hash fill factor. This is the untuned, out-of-the-box switch from DB_BTREE to DB_HASH. Disappointing initial results.
|
For reference: the problem with the stuck chain is probably due to incorrectly isolating blockchain modifications in transactions. This would only cause problems when a block fails to connect to the main chain. When downloading from the network, one does not receive older stales, but LoadExternalBlockFile does import these. The imported file seems to contain a block with an invalid BIP16 transaction at 173929, which indeed would cause an error when connecting the block to the chain. |
Issue 5 fixed. Thanks to @sipa for noticing the probable bug. |
db_stat output, after loading 180,953 blocks: http://pastebin.com/LEw3PQbL |
db_stat output, after loading 180,960 blocks the old way (blkindex.dat): http://pastebin.com/9DhQDCFc |
Merged several commits into one big one, and then refactored a bit into three pieces:
This arrangement permits easier testing of the database split itself (still btree) versus hash. |
db_stat output, with 3way split using DB_BTREE: http://pastebin.com/v9nZ6SCb |
blkindex.dat is overloaded to store three different datasets within a single key/value database: 1. uint256 hash -> CBlockIndex 2. uint256 hash -> CTxIndex 3. miscellaneous metadata associated with the block chain Split into three files, blkhash.dat, txhash.dat and blkmeta.dat, stored in the blockchain/ subdirectory. blk????.dat storage is also moved into the new blockchain/ subdirectory.
I think it would make sense to keep a tree-based index for the block header database, to allow looking up a block prefix quickly. In #1426 the idea rose to use the lower bytes as identifier instead of the higher ones. Maybe it makes sense to do a byteswap on the block header keys, to allow a lookup on those? |
Closing. Inclusion of this split is conditional on making other major changes to the database structure, such as TD's LevelDB changes. If/when those are merged, this can be updated and reopened. The net effect of this pull request was a 10% space savings and CPU util savings. |
Turn off for header and put node ID on second line so that header always has full width to display the IP (handles long IPv6 addresses). Turn on for user agent and services strings. NOTE: Required adding in a space to the separators between services as word wrap only works on whitespace characters for QLabels
…dialog 5a8084d [Trivial] fix typo "recomended" in sendcustomfee dialog (random-zebra) Pull request description: Closes bitcoin#1303 ACKs for top commit: furszy: utACK 5a8084d Tree-SHA512: 786d861360b0e8ee688a1873c33cecb514f8a03e83d20fe885fa809517c2560873728e268609eef0fd524b0a3104005d55306109cacce82a6d60b4f5e89ec331
OBSOLETES: #1282