Skip to content

Commit

Permalink
Make the compaction warning more tolerant and reduce cut limit
Browse files Browse the repository at this point in the history
  • Loading branch information
arpad-m committed Aug 17, 2023
1 parent 64fc7ea commit 132e3e7
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions pageserver/src/tenant/timeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3605,13 +3605,13 @@ impl Timeline {
.iter()
.map(|DeltaEntry { key, lsn, size, .. }| (*key, *lsn, *size))
.coalesce(|mut prev, cur| {
// Coalesce keys that belong to the same key pair.
// This ensures that compaction doesn't put them
// Coalesce key pairs that have the same key.
// This makes compaction not put them
// into different layer files.
// Still limit this by the target file size,
// so that we keep the size of the files in
// check.
if prev.0 == cur.0 && prev.2 < target_file_size {
// Still limit this by a quarter of the target
// file size, so that we don't overshoot the
// target by too much (by at most the liimt).
if prev.0 == cur.0 && prev.2 < target_file_size / 4 {
prev.2 += cur.2;
Ok(prev)
} else {
Expand Down Expand Up @@ -3778,7 +3778,10 @@ impl Timeline {
// Sync layers
if !new_layers.is_empty() {
// Print a warning if the created layer is larger than double the target size
let warn_limit = target_file_size * 2;
// Add two pages for potential overhead. This should in theory be already
// accounted for in the target calculation, but for very small targets,
// we still might easily hit the target.
let warn_limit = target_file_size * 2 + page_cache::PAGE_SZ as u64 * 2;
for layer in new_layers.iter() {
if layer.desc.file_size > warn_limit {
warn!(
Expand Down

0 comments on commit 132e3e7

Please sign in to comment.