-
Notifications
You must be signed in to change notification settings - Fork 813
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
Add file block storage #703
Conversation
This comment has been minimized.
This comment has been minimized.
e101f32
to
c459753
Compare
94b8a2b
to
1fa7ece
Compare
Here are some of the initial results with the benchmarks: FileBlockStore SSD
LevelBlockStore SSD
FileBlockStore HDD
LevelBlockStore HDD
For the complete breakdown of the performance of each operation see: https://gist.github.com/braydonf/952ace7bcd7bbf529516e16a1d11e67e |
Charts were generated via this branch: https://github.com/braydonf/bcoin/tree/blockstore-charts and this commit braydonf@5f1eec7 |
This PR does not yet integrate the block store to be used with the chain and node yet, @tuxcanfly has a work-in-progress branch at tuxcanfly@7d53f63 integrating the file block store with chain. And it's showing significant improvements to the initial sync time. From my testing it shaved around 12 hours from the sync for mainnet. |
1612c66
to
f219e56
Compare
Okay, this PR now integrates file blockstore with chain and the fullnode, and also rebased on latest master. |
Here are the results from logging
|
Tested with pruned and SPV nodes, and is working well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As benchmarks above show, there's a marked improvement in performance for writing files which boosts the initial sync time. LGTM with some minor updates 👍
I wonder if we should have a quick check to make sure all files are present. I renamed a
... though it couldn't add any new blocks to the chain (the file I mangled was the tip). Downstream in the logs some weird messages: I guess losing a file screwed up network sync also? Note Bitcoin Core runs this check at startup:
|
Should we include |
There is a scan at the startup for all |
For clarity there are several follow-up PRs after this one to:
|
There is potential for around a 10% to 23% increase to the performance of block reads by using `allocUnsafe`, however there is already around a 3 to 6 times increase to the performance. While it's safe to use `allocUnsafe` as the number of bytes read is checked to be the same size as the buffer allocation, there is a potential for test cases to introduce _other_ behavior for `fs.read` that may not have the same behavior, though this isn't currently the case.
Okay, I think this is ready to land. |
- Multiple parallel runs of the same test will not conflict as a unique identifier is added to the test directory. - The base test directory can be configured for various environments, and can be changed via the environment variable `TEMP`, see the implementation of `os.tmpdir()` for specific details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job with the extensive test cases. I like test/blockstore-test.js
.
Overall mostly nits, but this looks good to me. I have synced it a few times without a problem using Node.js v10.
This adds a new module
blockstore
for storing blocks. It adds a file block store that has several advantages:txindex
can point to this data instead of duplicating the tx data (Disk I/O efficiency improvements #585).There can be multiple implementations of the blockstore interface, to give better flexibility to how data is stored. Currently this includes
FileBlockStore
andLevelBlockStore
, this could later be expanded to other methods.