Skip to content
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

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

Open
spoonincode opened this issue Jan 26, 2025 · 1 comment
Labels

Comments

@spoonincode
Copy link
Member

This std::async(),

auto async_calculate_merkle_pow2 = [&start, &size](auto fut) {
size_t slice_size = size / fut.size();
for (size_t i=0; i<fut.size(); ++i)
fut[i] = std::async(std::launch::async, calculate_merkle_pow2<It>,
start + slice_size * i, start + slice_size * (i+1));
std::array<digest_type, fut.size()> res;
for (size_t i=0; i<fut.size(); ++i)
res[i] = fut[i].get();
return calculate_merkle_pow2(res.begin(), res.end());
};

leads to the full creation and destruction of at least 2 threads for every block. Would be nice to figure out how to use a thread pool here.

@greg7mdp
Copy link
Contributor

greg7mdp commented Jan 26, 2025

This merkle computation is about 25% faster than the one in 5.0, even when not using std::async. And in my tests, the async version is faster still, even with the overhead of starting a thread in std::async.
I feel we should not add code complexity unless we can show it makes a significant difference. There is a perf. test for the merkle functions in benchmarks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

3 participants