Skip to content

Commit cd73b3d

Browse files
authored
Reduce how much old WAL we keep around. (#7098)
Previously we were keeping up to around 6 hours of WAL around by removing 1/3 every hours. This was excessive, so switch to removing 2/3 which will up to around 3 hours of WAL around. This will roughly halve the size of the WAL and halve startup time for those who are I/O bound. This may increase the checkpoint size for those with certain churn patterns, but by much less than we're saving from the segments. Signed-off-by: Brian Brazil <[email protected]>
1 parent 3348930 commit cd73b3d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tsdb/head.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -681,9 +681,11 @@ func (h *Head) Truncate(mint int64) (err error) {
681681
if last < 0 {
682682
return nil // no segments yet.
683683
}
684-
// The lower third of segments should contain mostly obsolete samples.
685-
// If we have less than three segments, it's not worth checkpointing yet.
686-
last = first + (last-first)/3
684+
// The lower two thirds of segments should contain mostly obsolete samples.
685+
// If we have less than two segments, it's not worth checkpointing yet.
686+
// With the default 2h blocks, this will keeping up to around 3h worth
687+
// of WAL segments.
688+
last = first + (last-first)*2/3
687689
if last <= first {
688690
return nil
689691
}

0 commit comments

Comments
 (0)