-
Notifications
You must be signed in to change notification settings - Fork 206
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
Slow initial synchronization #235
Comments
Some months ago I ran blocks following with cProfile: more than 90% of the time is taken by the JSON RPC open connection.. So yes use a library to read the block files (#39) and avoid Json RPC for the initial synchro seems to be the best solution. |
I've created an initial implementation using python 3.4's new Ultimately, the initial sync is I/O bound, and bitcoind is the bottleneck. While a 2x-3x improvement is nice, we're still talking about many days to sync the initial database, which I think is unacceptable. A better solution would be to read the bitcoin blocks directly, bypassing bitcoind. |
That's a start! You run the test suite with |
Also, for those interested, you can bootstrap the database with a file from here: http://bootstrap.counterparty.co/ |
@mcelrath, would you mind making a pull request for these changes (from |
I saw that in the I'd be happy to submit a pull request but I'd like to test it a bit more and make sure I haven't screwed up something else. Also, if you guys are happy depending on python 3.4 and |
Thanks a lot for this. For anyone interested in the challenge, reading the block files directly would be great too (and we could use it as the preferred alternative to RPC-based sync if the block files were available). |
@xnova, what do you think about depending on Python 3.4, aiohttp? |
if we have to depend on python 3.4, bit may break windows compatibility. there is an APSW compiled for py3.4, but there is not a pycrypto I can find (at least from voidspace) compiled for py3.4 (only py3.3) EDIT: this guy talks about how he made one from scratch: http://flintux.wordpress.com/2014/04/30/pycrypto-for-python-3-4-on-windows-7-64bit/ This is an issue short term at least... I'm going to see how using docker under windows works out...if it's really slick I think I may want to move all windows people to just use that instead of the native windows builds...but otherwise we can keep the windows builds |
I got pytest installed, but the vast majority of tests fail even on I know python 3.4 is still pretty new, the windows packages will appear eventually. This problem of syncing to the bitcoin database will become worse with time though, but it can be merged later. It certainly would help adoption. I'm going to take a stab at reading the bitcoin dat files directly too. I doubt counterparty will be synced to my bitcoind by tomorrow, even with my asyncio changes. ;-) |
Run That'd be great if you could make it read the block files directly! |
Arg, I think it's failing because my database isn't caught up with bitcoind. :-( |
Guys I created this soon after the problems with the 64-bit of Python surfaced. It just needs to be "officialed" if there's a desire to support the building of the rare & unavailable binary Python packages which may become taxing. |
I'm having quite a difficult time finding a way to parse bitcoind's blk?????.dat files in python. |
What about python-libbitcoin, or libbitcoin (through Obelisk)? |
|
Armory may be an option as well, e. G. https://github.com/etotheipi/BitcoinArmory/blob/master/armoryengine/Block.py |
BTW your wiki says it takes 7-12 hours to sync with bitcoind. Is that old info? Or do I have a really slow hard drive? (probably both...) |
I'm pretty sure that Armory requires two on-disk copies of the blockchain. |
@mcelrath, I don't know how long it takes these days, though the time should be roughly proportional to the number of Bitcoin (not Counterparty) transactions since block 278000. |
FWIW, I've printed out the times to load blocks, on my computer it's 5.89s (wall time) per block (average over the last 28k blocks or so). That comes out to 2.6 days using my asyncio code at the current block height. (A lot better than my estimate using the original code, but still...) This should finish by tomorrow morning and I can run the tests and give you guys a pull request. |
maybe this can help : 2014-08-19 21:44 GMT+01:00 Bob McElrath notifications@github.com:
|
see also this: 2014-08-19 22:09 GMT+01:00 Ouziel Slama lightzarlboro@gmail.com:
|
FYI, the windows build is updated to use python 3.4.1, so we should be good here from a windows standpoint |
I've now changed the usage of What this all means is that if you call functions in A separate question is should this asynchronicity be extended to counterpartyd's API Server (possibly replacing tornado). I don't think counterpartyd will be performance limited in the foreseeable future, and we can cross that bridge when we come to it. All tests pass except Remaining to do before a Pull Request:
|
The -dbcache switch to bitcoind may help since it increases the amount of memory bitcoind allocates to database caching so reduces disk io. Using it with 128 or 256 should help but it would be interesting to know the exact speedup on an initial sync from bootstrap.dat stock vs 256. |
In progress solution: #362 |
@mcelrath: "The counterparty database is exceedingly slow to synchronize with the bitcoin database. It is taking about 35s per block, and given where it is in the blockchain, this will take 12 days to synchronize. It appears this is being caused by bitcoind doing I/O, not counterpartyd doing processing (my CPU is only about 10% loaded). Could counterparty be optimized to not hammer bitcoind so hard? Could bitcoind be optimized to not hammer the disk so hard?" (https://github.com/CounterpartyXCP/Counterparty/issues/5)
See also #128.
The text was updated successfully, but these errors were encountered: