clusterlin: adopt trained cost model (feature)

See the comments for the SFLDefaultCostModel class for details on how
the numbers were obtained.
This commit is contained in:
Pieter Wuille
2026-02-05 16:02:19 -05:00
parent 4eefdfc5b7
commit 744d47fcee
3 changed files with 59 additions and 22 deletions

View File

@@ -1021,6 +1021,7 @@ FUZZ_TARGET(clusterlin_linearize)
try {
reader >> VARINT(max_cost) >> Using<DepGraphFormatter>(depgraph) >> rng_seed >> flags;
} catch (const std::ios_base::failure&) {}
if (depgraph.TxCount() <= 1) return;
bool make_connected = flags & 1;
// The following 3 booleans have 4 combinations:
// - (flags & 6) == 0: do not provide input linearization.

View File

@@ -402,14 +402,14 @@ inline uint64_t MaxOptimalLinearizationCost(DepGraphIndex cluster_count)
// *some* reasonable cost bound, optimal linearizations are always found.
static constexpr uint64_t COSTS[65] = {
0,
0, 176, 440, 1496, 3344, 6864, 10076, 16720,
19404, 22748, 29832, 41052, 45628, 60104, 64416, 75284,
92884, 111848, 134992, 137104, 177276, 152548, 234256, 237688,
285164, 315084, 327404, 360052, 389092, 411532, 488576, 504020,
518804, 553080, 593120, 627396, 639100, 546744, 636988, 888844,
824428, 729564, 1039368, 1253384, 1348688, 1452924, 1449448, 1440780,
1498024, 1153988, 1525128, 1672836, 1795816, 1368972, 1823712, 1494592,
1541056, 2605108, 1886368, 1816188, 1864060, 2280652, 2790040, 2949540
0, 545, 928, 1633, 2647, 4065, 5598, 8258,
9505, 11471, 14137, 19553, 20460, 26191, 28397, 32599,
41631, 47419, 56329, 57767, 72196, 63652, 95366, 96537,
115653, 125407, 131734, 145090, 156349, 164665, 194224, 203953,
207710, 225878, 239971, 252284, 256534, 222142, 251332, 357098,
325788, 295867, 410053, 497483, 533892, 576572, 577845, 572400,
592536, 455082, 609249, 659130, 714091, 544507, 718788, 562378,
601926, 1025081, 732725, 708896, 738224, 900445, 1092519, 1139946
};
assert(cluster_count < std::size(COSTS));
// Multiply the table number by two, to account for the fact that they are not absolutes.