clusterlin: permit passing in existing linearization to Linearize

This implements the LIMO algorithm for linearizing by improving an existing
linearization. See
https://delvingbitcoin.org/t/limo-combining-the-best-parts-of-linearization-search-and-merging
for details.
This commit is contained in:
Pieter Wuille
2024-05-09 09:02:18 -04:00
parent 97d98718b0
commit 28549791b3
3 changed files with 53 additions and 9 deletions

View File

@@ -109,7 +109,7 @@ void BenchLinearizePerIterWorstCase(ClusterIndex ntx, benchmark::Bench& bench)
});
}
/** Benchmark for linearization of a trivial linear graph using just ancestor sort.
/** Benchmark for linearization improvement of a trivial linear graph using just ancestor sort.
*
* Its goal is measuring how much time linearization may take without any search iterations.
*
@@ -124,8 +124,10 @@ void BenchLinearizeNoItersWorstCase(ClusterIndex ntx, benchmark::Bench& bench)
{
const auto depgraph = MakeLinearGraph<SetType>(ntx);
uint64_t rng_seed = 0;
std::vector<ClusterIndex> old_lin(ntx);
for (ClusterIndex i = 0; i < ntx; ++i) old_lin[i] = i;
bench.run([&] {
Linearize(depgraph, /*max_iterations=*/0, rng_seed++);
Linearize(depgraph, /*max_iterations=*/0, rng_seed++, old_lin);
});
}