mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
txgraph: Delay chunking while sub-acceptable (optimization)
Chunk-based information (primarily, chunk feerates) are never accessed without first bringing the relevant Clusters to an "acceptable" quality level. Thus, while operations are ongoing and Clusters are not acceptable, we can omit computing the chunkings and chunk feerates for Clusters.
This commit is contained in:
parent
57f5499882
commit
5801e0fb2b
1 changed files with 26 additions and 24 deletions
|
@ -331,8 +331,11 @@ void Cluster::Updated(TxGraphImpl& graph) noexcept
|
|||
auto& entry = graph.m_entries[m_mapping[idx]];
|
||||
entry.m_locator.SetPresent(this, idx);
|
||||
}
|
||||
|
||||
// Compute its chunking and store its information in the Entry's m_chunk_feerate.
|
||||
// If the Cluster's quality is ACCEPTABLE or OPTIMAL, compute its chunking and store its
|
||||
// information in the Entry's m_chunk_feerate. These fields are only accessed after making
|
||||
// the entire graph ACCEPTABLE, so it is pointless to compute these if we haven't reached that
|
||||
// quality level yet.
|
||||
if (IsAcceptable()) {
|
||||
LinearizationChunking chunking(m_depgraph, m_linearization);
|
||||
LinearizationIndex lin_idx{0};
|
||||
// Iterate over the chunks.
|
||||
|
@ -349,6 +352,7 @@ void Cluster::Updated(TxGraphImpl& graph) noexcept
|
|||
chunk.transactions.Reset(idx);
|
||||
} while(chunk.transactions.Any());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Cluster::ApplyRemovals(TxGraphImpl& graph, std::span<GraphIndex>& to_remove) noexcept
|
||||
|
@ -409,8 +413,6 @@ bool Cluster::Split(TxGraphImpl& graph) noexcept
|
|||
// The existing Cluster is an entire component. Leave it be, but update its quality.
|
||||
Assume(todo == m_depgraph.Positions());
|
||||
graph.SetClusterQuality(m_quality, m_setindex, QualityLevel::NEEDS_RELINEARIZE);
|
||||
// We need to recompute and cache its chunking.
|
||||
Updated(graph);
|
||||
return false;
|
||||
}
|
||||
first = false;
|
||||
|
@ -1262,12 +1264,12 @@ void Cluster::SanityCheck(const TxGraphImpl& graph) const
|
|||
assert(entry.m_locator.cluster == this);
|
||||
assert(entry.m_locator.index == lin_pos);
|
||||
// Check linearization position and chunk feerate.
|
||||
if (IsAcceptable()) {
|
||||
if (!linchunking.GetChunk(0).transactions[lin_pos]) {
|
||||
linchunking.MarkDone(linchunking.GetChunk(0).transactions);
|
||||
}
|
||||
assert(entry.m_chunk_feerate == linchunking.GetChunk(0).feerate);
|
||||
// If this Cluster has an acceptable quality level, its chunks must be connected.
|
||||
if (IsAcceptable()) {
|
||||
assert(m_depgraph.IsConnected(linchunking.GetChunk(0).transactions));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue