Skip to content

Commit

Permalink
Reduce how much old WAL we keep around. (#7098)
Browse files Browse the repository at this point in the history
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 <brian.brazil@robustperception.io>
  • Loading branch information
brian-brazil committed Apr 7, 2020
1 parent 3348930 commit cd73b3d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tsdb/head.go
Expand Up @@ -681,9 +681,11 @@ func (h *Head) Truncate(mint int64) (err error) {
if last < 0 {
return nil // no segments yet.
}
// The lower third of segments should contain mostly obsolete samples.
// If we have less than three segments, it's not worth checkpointing yet.
last = first + (last-first)/3
// The lower two thirds of segments should contain mostly obsolete samples.
// If we have less than two segments, it's not worth checkpointing yet.
// With the default 2h blocks, this will keeping up to around 3h worth
// of WAL segments.
last = first + (last-first)*2/3
if last <= first {
return nil
}
Expand Down

0 comments on commit cd73b3d

Please sign in to comment.