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 · 2 comments
Labels
enhancement New feature or request 👍 lgtm

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.

@bhazzard bhazzard added enhancement New feature or request 👍 lgtm and removed triage labels Feb 6, 2025
@bhazzard
Copy link

bhazzard commented Feb 6, 2025

Not a high priority, to be explored opportunistically, considering impacts to code clarity and performance on replay / sync use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 👍 lgtm
Projects
Status: Todo
Development

No branches or pull requests

4 participants