clusterlin: rescale costs (preparation)

This commit is contained in:
Pieter Wuille
2026-02-21 10:27:59 -05:00
committed by Pieter Wuille
parent ecc9a84f85
commit 4eefdfc5b7
4 changed files with 13 additions and 13 deletions

View File

@@ -486,9 +486,9 @@ public:
inline void StartOptimizingBegin() noexcept {} inline void StartOptimizingBegin() noexcept {}
inline void StartOptimizingEnd(int num_chunks) noexcept {} inline void StartOptimizingEnd(int num_chunks) noexcept {}
inline void ActivateBegin() noexcept {} inline void ActivateBegin() noexcept {}
inline void ActivateEnd(int num_deps) noexcept { m_cost += num_deps + 1; } inline void ActivateEnd(int num_deps) noexcept { m_cost += 38 * num_deps + 38; }
inline void DeactivateBegin() noexcept {} inline void DeactivateBegin() noexcept {}
inline void DeactivateEnd(int num_deps) noexcept { m_cost += num_deps + 1; } inline void DeactivateEnd(int num_deps) noexcept { m_cost += 38 * num_deps + 38; }
inline void MergeChunksBegin() noexcept {} inline void MergeChunksBegin() noexcept {}
inline void MergeChunksMid(int num_txns) noexcept {} inline void MergeChunksMid(int num_txns) noexcept {}
inline void MergeChunksEnd(int num_steps) noexcept {} inline void MergeChunksEnd(int num_steps) noexcept {}

View File

@@ -1043,7 +1043,7 @@ FUZZ_TARGET(clusterlin_linearize)
} }
// Invoke Linearize(). // Invoke Linearize().
max_cost &= 0x7ffff; max_cost &= 0x3fffff;
auto [linearization, optimal, cost] = Linearize( auto [linearization, optimal, cost] = Linearize(
/*depgraph=*/depgraph, /*depgraph=*/depgraph,
/*max_cost=*/max_cost, /*max_cost=*/max_cost,
@@ -1242,7 +1242,7 @@ FUZZ_TARGET(clusterlin_postlinearize_tree)
// Try to find an even better linearization directly. This must not change the diagram for the // Try to find an even better linearization directly. This must not change the diagram for the
// same reason. // same reason.
auto [opt_linearization, _optimal, _cost] = Linearize(depgraph_tree, 100000, rng_seed, IndexTxOrder{}, post_linearization); auto [opt_linearization, _optimal, _cost] = Linearize(depgraph_tree, 1000000, rng_seed, IndexTxOrder{}, post_linearization);
auto opt_chunking = ChunkLinearization(depgraph_tree, opt_linearization); auto opt_chunking = ChunkLinearization(depgraph_tree, opt_linearization);
auto cmp_opt = CompareChunks(opt_chunking, post_chunking); auto cmp_opt = CompareChunks(opt_chunking, post_chunking);
assert(cmp_opt == 0); assert(cmp_opt == 0);

View File

@@ -402,14 +402,14 @@ inline uint64_t MaxOptimalLinearizationCost(DepGraphIndex cluster_count)
// *some* reasonable cost bound, optimal linearizations are always found. // *some* reasonable cost bound, optimal linearizations are always found.
static constexpr uint64_t COSTS[65] = { static constexpr uint64_t COSTS[65] = {
0, 0,
0, 4, 10, 34, 76, 156, 229, 380, 0, 176, 440, 1496, 3344, 6864, 10076, 16720,
441, 517, 678, 933, 1037, 1366, 1464, 1711, 19404, 22748, 29832, 41052, 45628, 60104, 64416, 75284,
2111, 2542, 3068, 3116, 4029, 3467, 5324, 5402, 92884, 111848, 134992, 137104, 177276, 152548, 234256, 237688,
6481, 7161, 7441, 8183, 8843, 9353, 11104, 11455, 285164, 315084, 327404, 360052, 389092, 411532, 488576, 504020,
11791, 12570, 13480, 14259, 14525, 12426, 14477, 20201, 518804, 553080, 593120, 627396, 639100, 546744, 636988, 888844,
18737, 16581, 23622, 28486, 30652, 33021, 32942, 32745, 824428, 729564, 1039368, 1253384, 1348688, 1452924, 1449448, 1440780,
34046, 26227, 34662, 38019, 40814, 31113, 41448, 33968, 1498024, 1153988, 1525128, 1672836, 1795816, 1368972, 1823712, 1494592,
35024, 59207, 42872, 41277, 42365, 51833, 63410, 67035 1541056, 2605108, 1886368, 1816188, 1864060, 2280652, 2790040, 2949540
}; };
assert(cluster_count < std::size(COSTS)); assert(cluster_count < std::size(COSTS));
// Multiply the table number by two, to account for the fact that they are not absolutes. // Multiply the table number by two, to account for the fact that they are not absolutes.

View File

@@ -51,7 +51,7 @@ static const uint32_t MEMPOOL_HEIGHT = 0x7FFFFFFF;
/** How much linearization cost required for TxGraph clusters to have /** How much linearization cost required for TxGraph clusters to have
* "acceptable" quality, if they cannot be optimally linearized with less cost. */ * "acceptable" quality, if they cannot be optimally linearized with less cost. */
static constexpr uint64_t ACCEPTABLE_COST = 1'700; static constexpr uint64_t ACCEPTABLE_COST = 75'000;
/** How much work we ask TxGraph to do after a mempool change occurs (either /** How much work we ask TxGraph to do after a mempool change occurs (either
* due to a changeset being applied, a new block being found, or a reorg). */ * due to a changeset being applied, a new block being found, or a reorg). */