-
Notifications
You must be signed in to change notification settings - Fork 808
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
Migrate to promises once they're optimized enough #71
Comments
Putting out a 1BTC bounty to anyone who can optimize the generators branch, such that it is near or less than 100mb heapsize during the initial checkpoints sync from a fast node (should always have 500 pending blocks after a getblocks). |
Have you tried using bluebird instead of native promises? See http://programmers.stackexchange.com/questions/278778/why-are-native-es6-promises-slower-and-more-memory-intensive-than-bluebird Replace spawn with Promise.coroutine (bluebird method) |
I've tried using bluebird instead of native es6 promises. I didn't see a substantial difference in perf or memory usage. They seemed roughly the same. I'm starting to suspect generators and the state v8 has to hold along with them are the actual bottleneck here. Unfortunately generator functions can't be reimplemented externally. That being said, I haven't tried bluebird's coroutine method. I'll check that out. I'm hoping I just used some kind of anti pattern here that I'm not aware of in my use of generators. |
@bpdavenport You've earned yourself 1btc. Bluebird was exactly where I needed to look. I knew there was some kind of antipattern I was doing. Bluebird's convention is to define the function as You can post an address here. I'd say email it to me, but I don't have your gpg key (a quick keybase search yielded nothing), and I have nothing else to verify your identity on any other platform. |
@bpdavenport shot an email your way. Closing now. |
The generators branch is a rewrite of bcoin using promises and generators: https://github.com/bcoin-org/bcoin/tree/generators
Unfortunately, promises and generators are slow and use a lot of memory when compared to callbacks (initial sync: 1ms block processing time vs 400 usec block processing time, 160-200mb heap size vs 75mb heap size, high watermark of 110mb heapused vs 50mb heapused).
Once async/await becomes ubiquitous, I see bcoin switching to that, but only if it is well optimized.
If anyone can optimize the generators branch, I'd be willing to switch now.
The text was updated successfully, but these errors were encountered: