Skip to content

Commit

Permalink
Merge pull request #564 from evoskuil/master
Browse files Browse the repository at this point in the history
Switch to unconditional execution policy.
  • Loading branch information
evoskuil authored Feb 10, 2025
2 parents 667515b + e31dee8 commit 86ae17e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
10 changes: 5 additions & 5 deletions include/bitcoin/database/impl/query/consensus.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ bool CLASS::populate_prevouts(spend_sets& sets) const NOEXCEPT
TEMPLATE
code CLASS::block_confirmable(const header_link& link) const NOEXCEPT
{
constexpr auto parallel = bc::par_unseq;
constexpr auto parallel = poolstl::execution::par;

context ctx{};
if (!get_context(ctx, link))
Expand All @@ -403,12 +403,12 @@ code CLASS::block_confirmable(const header_link& link) const NOEXCEPT
if (!get_spend_set(set, tx))
failure.store(error::integrity8);

spends += set.spends.size();
spends.fetch_add(set.spends.size(), std::memory_order_relaxed);
return set;
};

// 14.99%
std_transform(parallel, txs.begin(), txs.end(), sets.begin(), to_set);
std::transform(parallel, txs.begin(), txs.end(), sets.begin(), to_set);
if (failure)
return { failure.load() };

Expand Down Expand Up @@ -441,11 +441,11 @@ code CLASS::block_confirmable(const header_link& link) const NOEXCEPT
};

// 43.83%
if (std_any_of(parallel, sets.begin(), sets.end(), is_unspendable))
if (std::any_of(parallel, sets.begin(), sets.end(), is_unspendable))
return { failure.load() };

// 37.55%
if (std_any_of(parallel, sets.begin(), sets.end(), is_spent))
if (std::any_of(parallel, sets.begin(), sets.end(), is_spent))
return { failure.load() };

return error::success;
Expand Down
6 changes: 4 additions & 2 deletions include/bitcoin/database/impl/query/extent.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,17 @@ two_counts CLASS::put_counts(const tx_link& link) const NOEXCEPT
TEMPLATE
size_t CLASS::input_count(const tx_links& txs) const NOEXCEPT
{
constexpr auto parallel = poolstl::execution::par;
const auto fn = [this](auto tx) NOEXCEPT { return input_count(tx); };
return std_reduce(bc::par_unseq, txs.begin(), txs.end(), zero, fn);
return std::reduce(parallel, txs.begin(), txs.end(), zero, fn);
}

TEMPLATE
size_t CLASS::output_count(const tx_links& txs) const NOEXCEPT
{
constexpr auto parallel = poolstl::execution::par;
const auto fn = [this](auto tx) NOEXCEPT { return output_count(tx); };
return std_reduce(bc::par_unseq, txs.begin(), txs.end(), zero, fn);
return std::reduce(parallel, txs.begin(), txs.end(), zero, fn);
}

TEMPLATE
Expand Down
3 changes: 2 additions & 1 deletion include/bitcoin/database/impl/query/translate.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -428,12 +428,13 @@ output_links CLASS::to_outputs(const tx_links& txs) const NOEXCEPT
TEMPLATE
output_links CLASS::to_prevouts(const tx_links& txs) const NOEXCEPT
{
constexpr auto parallel = poolstl::execution::par;
const auto ins = to_spends(txs);
output_links outs(ins.size());
const auto fn = [this](auto spend) NOEXCEPT{ return to_prevout(spend); };

// C++17 incomplete on GCC/CLang, so presently parallel only on MSVC++.
std_transform(bc::par_unseq, ins.begin(), ins.end(), outs.begin(), fn);
std::transform(parallel, ins.begin(), ins.end(), outs.begin(), fn);
return outs;
}

Expand Down

0 comments on commit 86ae17e

Please sign in to comment.