-
Notifications
You must be signed in to change notification settings - Fork 33
use a global merkle thread pool to avoid creation and destruction of threads every block #1412
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
|
|
||
| struct merkle_pool { | ||
| merkle_pool() { | ||
| thread_pool.start(4, [](const fc::exception&){}, [](size_t){}); |
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.
idk what to do with exceptions off hand here. Need to think about it
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.
Log the exception and std::exit(-2);. Exceptions should be completely unexpected. If they can happen then they should be caught and handled as a bad hash in calculate_merkle_pow2.
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.
I had to check it worked like I would have guess -- and yeah, when using use_future exceptions thrown inside of the dispatched work do get packaged in to the future. So if you're only post()ing use_futures then it is completely unexpected for anything to leak out.
It might be useful for named_thread_pool to provide some pre-defined functions one can pick up and use. thread_pool.start(4, named_thread_pool::abort_on_exception,...) or something. Will just do something locally here for now. I'm not sure exit() is the right choice since it seems like you'd want something more aborty
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.
std::abort() does make sense here.
It does seem having a named_thread_pool::abort_on_exception would be handy.
I like this better than the original. I feel that a benefit of having the thread pool in appbase, and our custom |
| abort(); | ||
| }; | ||
| } | ||
|
|
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.
I wanted to make a make_on_except_quit_appbase() and then replace a number of usages of that across the code but libchain does not depend on appbase so I can't do that here. oh well 😞
Like #1398 but using this approach #1398 (comment)