mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 23:09:44 -04:00
txgraph: make number of acceptable iterations configurable (feature)
This commit is contained in:
parent
b074308e6f
commit
79ef423f42
3 changed files with 13 additions and 7 deletions
|
@ -272,9 +272,11 @@ FUZZ_TARGET(txgraph)
|
|||
auto max_count = provider.ConsumeIntegralInRange<DepGraphIndex>(1, MAX_CLUSTER_COUNT_LIMIT);
|
||||
// And the maximum combined size of transactions per cluster.
|
||||
auto max_size = provider.ConsumeIntegralInRange<uint64_t>(1, 0x3fffff * MAX_CLUSTER_COUNT_LIMIT);
|
||||
// And the number of iterations to consider a cluster acceptably linearized.
|
||||
auto acceptable_iters = provider.ConsumeIntegralInRange<uint64_t>(0, 10000);
|
||||
|
||||
// Construct a real graph, and a vector of simulated graphs (main, and possibly staging).
|
||||
auto real = MakeTxGraph(max_count, max_size);
|
||||
auto real = MakeTxGraph(max_count, max_size, acceptable_iters);
|
||||
std::vector<SimTxGraph> sims;
|
||||
sims.reserve(2);
|
||||
sims.emplace_back(max_count, max_size);
|
||||
|
|
|
@ -247,6 +247,8 @@ private:
|
|||
const DepGraphIndex m_max_cluster_count;
|
||||
/** This TxGraphImpl's maximum cluster size limit. */
|
||||
const uint64_t m_max_cluster_size;
|
||||
/** The number of linearization improvements steps needed for it to be considered acceptable. */
|
||||
const uint64_t m_acceptable_iters;
|
||||
|
||||
/** Information about one group of Clusters to be merged. */
|
||||
struct GroupEntry
|
||||
|
@ -443,9 +445,10 @@ private:
|
|||
|
||||
public:
|
||||
/** Construct a new TxGraphImpl with the specified limits. */
|
||||
explicit TxGraphImpl(DepGraphIndex max_cluster_count, uint64_t max_cluster_size) noexcept :
|
||||
explicit TxGraphImpl(DepGraphIndex max_cluster_count, uint64_t max_cluster_size, uint64_t acceptable_iters) noexcept :
|
||||
m_max_cluster_count(max_cluster_count),
|
||||
m_max_cluster_size(max_cluster_size),
|
||||
m_acceptable_iters(acceptable_iters),
|
||||
m_main_chunkindex(ChunkOrder(this))
|
||||
{
|
||||
Assume(max_cluster_count >= 1);
|
||||
|
@ -1671,7 +1674,7 @@ uint64_t TxGraphImpl::MakeAcceptable(Cluster& cluster) noexcept
|
|||
uint64_t cost{0};
|
||||
// Relinearize the Cluster if needed.
|
||||
if (!cluster.NeedsSplitting() && !cluster.IsAcceptable() && !cluster.IsOversized()) {
|
||||
cost += cluster.Relinearize(*this, 10000);
|
||||
cost += cluster.Relinearize(*this, m_acceptable_iters);
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
|
@ -2896,7 +2899,7 @@ TxGraph::Ref::Ref(Ref&& other) noexcept
|
|||
std::swap(m_index, other.m_index);
|
||||
}
|
||||
|
||||
std::unique_ptr<TxGraph> MakeTxGraph(unsigned max_cluster_count, uint64_t max_cluster_size) noexcept
|
||||
std::unique_ptr<TxGraph> MakeTxGraph(unsigned max_cluster_count, uint64_t max_cluster_size, uint64_t acceptable_iters) noexcept
|
||||
{
|
||||
return std::make_unique<TxGraphImpl>(max_cluster_count, max_cluster_size);
|
||||
return std::make_unique<TxGraphImpl>(max_cluster_count, max_cluster_size, acceptable_iters);
|
||||
}
|
||||
|
|
|
@ -247,7 +247,8 @@ public:
|
|||
|
||||
/** Construct a new TxGraph with the specified limit on transactions within a cluster, and the
|
||||
* specified limit on the sum of transaction sizes within a cluster. max_cluster_count cannot
|
||||
* exceed MAX_CLUSTER_COUNT_LIMIT. */
|
||||
std::unique_ptr<TxGraph> MakeTxGraph(unsigned max_cluster_count, uint64_t max_cluster_size) noexcept;
|
||||
* exceed MAX_CLUSTER_COUNT_LIMIT. acceptable_iters controls how many linearization optimization
|
||||
* steps will be performed before it is considered to be of acceptable quality. */
|
||||
std::unique_ptr<TxGraph> MakeTxGraph(unsigned max_cluster_count, uint64_t max_cluster_size, uint64_t acceptable_iters) noexcept;
|
||||
|
||||
#endif // BITCOIN_TXGRAPH_H
|
||||
|
|
Loading…
Add table
Reference in a new issue