Skip to content

Commit cc85dfb

Browse files
committed
[mpt] Scale slow-list compaction by gc_efficiency relative to disk growth
Replace the fixed cap (min of growth+1 and gc_efficiency) with a formula that scales growth by gc_efficiency / breakeven. Above the breakeven (4), compaction outruns growth to reduce backlog; below it, compaction backs off when recirculation is heavy.
1 parent 963a826 commit cc85dfb

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

category/mpt/update_aux.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,22 +1490,25 @@ void UpdateAuxImpl::advance_compact_offsets(Node::SharedPtr const prev_root)
14901490
// <-- Slow list compaction -->
14911491
constexpr double usage_limit_start_compact_slow = 0.6;
14921492
constexpr double slow_usage_limit_start_compact_slow = 0.2;
1493+
constexpr uint32_t gc_efficiency_breakeven = 4;
1494+
14931495
double const slow_disk_usage =
14941496
num_chunks(chunk_list::slow) / (double)io->chunk_count();
14951497
// Do not compact slow list until slow list usage and total usage are both
14961498
// above the thresholds
14971499
if (disk_usage() > usage_limit_start_compact_slow &&
14981500
slow_disk_usage > slow_usage_limit_start_compact_slow) {
1499-
// Compact slow ring: the offset is based on slow list garbage
1500-
// collection ratio of the last block. We use the ratio of compacted
1501-
// bytes to determine how aggressively to advance the compaction head.
1501+
// Compact slow ring at growth rate scaled by gc_efficiency.
1502+
// The breakeven point is 4, above which we compact faster than
1503+
// growth (reduce backlog), below 4 we compact slower (back off
1504+
// when recirculation is heavy).
15021505
uint32_t to_advance =
1503-
1; // No active data in last compaction, use minimum progress
1506+
3; // No active data in last compaction, use minimum progress
15041507
if (last_block_slow_list_gc_efficiency_ > 0) {
1505-
// Cap at last block's growth + 1 to avoid advancing too fast
1506-
to_advance = std::min(
1507-
static_cast<uint32_t>(last_block_disk_growth_slow_ + 1),
1508-
last_block_slow_list_gc_efficiency_);
1508+
to_advance = static_cast<uint32_t>(
1509+
static_cast<uint64_t>(last_block_disk_growth_slow_) *
1510+
last_block_slow_list_gc_efficiency_ / gc_efficiency_breakeven);
1511+
to_advance = std::min(to_advance, max_compact_offset_range);
15091512
}
15101513
compact_offset_range_slow_.set_value(to_advance);
15111514
compact_offsets.slow += compact_offset_range_slow_;

0 commit comments

Comments
 (0)