POC for compacting earlier than 1.5x of block size

Signed-off-by: Ganesh Vernekar <ganesh.vernekar@reddit.com>
This commit is contained in:
Ganesh Vernekar 2025-06-27 08:29:02 -07:00
parent 9e73fb43b3
commit ca9688131b
2 changed files with 4 additions and 2 deletions

View File

@ -62,6 +62,8 @@ var (
defaultIsolationDisabled = false
defaultWALReplayConcurrency = runtime.GOMAXPROCS(0)
compactibleRatio = 1.1
)
// Head handles reads and writes of time series data within a time window.
@ -1700,7 +1702,7 @@ func (h *Head) compactable() bool {
return false
}
return h.MaxTime()-h.MinTime() > h.chunkRange.Load()/2*3
return h.MaxTime()-h.MinTime() > int64(float64(h.chunkRange.Load())*compactibleRatio)
}
// Close flushes the WAL and closes the head.

View File

@ -194,7 +194,7 @@ func (h *Head) appender() *headAppender {
func (h *Head) appendableMinValidTime() int64 {
// This boundary ensures that no samples will be added to the compaction window.
// This allows race-free, concurrent appending and compaction.
cwEnd := h.MaxTime() - h.chunkRange.Load()/2
cwEnd := h.MaxTime() - int64(float64(h.chunkRange.Load())*(compactibleRatio-1))
// This boundary ensures that we avoid overlapping timeframes from one block to the next.
// While not necessary for correctness, it means we're not required to use vertical compaction.