Skip to content

Conversation

@spoonincode
Copy link
Contributor

Like #1398 but using this approach #1398 (comment)


struct merkle_pool {
merkle_pool() {
thread_pool.start(4, [](const fc::exception&){}, [](size_t){});
Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.

@greg7mdp
Copy link
Contributor

Like #1398 but using this approach #1398 (comment)

I like this better than the original.

I feel that a benefit of having the thread pool in appbase, and our custom async version, is that we can use this in other algorithms, without having to have another static thread_pool. So I think it would be a better solution, but I guess we can always move to it when (or if) the need arises.

abort();
};
}

Copy link
Contributor Author

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 😞

@spoonincode spoonincode marked this pull request as ready for review April 21, 2025 21:49
@spoonincode spoonincode merged commit 24818bb into main Apr 22, 2025
36 checks passed
@spoonincode spoonincode deleted the global_merkle_tp branch April 22, 2025 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

on every block at least 2 threads are created and destroyed via merkle async

4 participants