Skip to content

Conversation

@sipa
Copy link
Member

@sipa sipa commented Dec 16, 2025

Part of #30289, follow-up to #32545.

This gets rid of FixLinearization() by integrating the functionality into Linearize(), and makes txgraph exploit that (by delaying fixing of clusters until their first re-linearization). It also reduces (but does not eliminate) the number of calls to PostLinearize, as the SFL linearization effectively performs something very similar to postlinearization when loading in an existing linearization already.

@DrahtBot
Copy link
Contributor

DrahtBot commented Dec 16, 2025

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34085.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK marcofleon, instagibbs

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #34138 (Cluster mempool: more accurate cost model for SFL by sipa)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

LLM Linter (✨ experimental)

Possible places where named args for integral literals may be used (e.g. func(x, /*named_arg=*/0) in C++, and func(x, named_arg=0) in Python):

  • graph.SetClusterQuality(level, m_quality, m_setindex, QualityLevel::NEEDS_FIX) in src/txgraph.cpp
  • graph.SetClusterQuality(level, m_quality, m_setindex, QualityLevel::NEEDS_RELINEARIZE) in src/txgraph.cpp

(No other added lines contain function calls where a third-or-later positional argument is a literal)

2026-01-05

@sipa
Copy link
Member Author

sipa commented Dec 19, 2025

Rebased after merge of #32545, and marked as ready for review.

Copy link
Member

@instagibbs instagibbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 159bd23

Only a few suggestions

@fanquake fanquake added this to the 31.0 milestone Dec 29, 2025
@sipa sipa force-pushed the 202512_txgraph_sfl branch from 159bd23 to d9fd076 Compare December 29, 2025 22:09
@instagibbs
Copy link
Member

reACK d9fd076

sipa added 5 commits January 5, 2026 11:48
This also updates FixLinearization to just be a thin wrapper around Linearize.
In a future commit, FixLinearization will be removed entirely.
With the SFL algorithm, we will practically be capable of keeping
most if not all clusters optimal. With that, it seems less valuable
to avoid doing work after splitting an acceptable cluster, because by
doing some work we may get it to OPTIMAL.

This reduces the complexity of the code a bit as well.
With the new SFL algorithm, the process of loading an existing linearization into the
SFL state is very similar to what PostLinearize does. This means there is little benefit
to performing an explicit PostLinearize step before linearizing inside txgraph. Instead,
it seems better to use our allotted CPU time to perform more SFL optimization steps.
@sipa sipa force-pushed the 202512_txgraph_sfl branch from d9fd076 to 1808b5a Compare January 5, 2026 16:49
Copy link
Contributor

@marcofleon marcofleon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code review ACK 1808b5a

Makes sense to defer making a cluster topological until the linearization is actually needed.

I also ran the new clusterlin_linearize fuzz target for a while, no issues.

auto component = m_depgraph.FindConnectedComponent(todo);
auto component_size = component.Count();
auto split_quality = component_size <= 2 ? QualityLevel::OPTIMAL : new_quality;
auto split_quality = component_size <= 1 ? QualityLevel::OPTIMAL : new_quality;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cluster components of two transactions are no longer guaranteed to be topological while splitting! Nice.


uint64_t GenericClusterImpl::AppendTrimData(std::vector<TrimTxData>& ret, std::vector<std::pair<GraphIndex, GraphIndex>>& deps) const noexcept
{
Assume(IsAcceptable());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Would it make sense to add this check in GenericClusterImpl::AppendChunkFeerates too? Maybe only for consistency.

@DrahtBot DrahtBot requested a review from instagibbs January 6, 2026 14:41
@instagibbs
Copy link
Member

reACK 1808b5a

Clean rebase + one comment typo fixed only

@fanquake fanquake merged commit c60f9cb into bitcoin:master Jan 6, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants