Skip to content

Commit

Permalink
feat: Call SingleGenerationReason() once by initializing a
Browse files Browse the repository at this point in the history
var called SingleGenerationReasonText var
  • Loading branch information
devanbenz committed Dec 19, 2024
1 parent cf657a8 commit fc6ca13
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion tsdb/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ const (

// MaxTSMFileSize is the maximum size of TSM files.
MaxTSMFileSize = uint32(2048 * 1024 * 1024) // 2GB

)

var SingleGenerationReasonText string = SingleGenerationReason()

// SingleGenerationReason outputs a log message for our single generation compaction
// when checked for full compaction.
// 1048576000 is a magic number for bytes per gigabyte.
Expand Down
2 changes: 1 addition & 1 deletion tsdb/engine/tsm1/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func (c *DefaultPlanner) FullyCompacted() (bool, string) {
}

if filesUnderMaxTsmSizeCount > 1 && aggressivePointsPerBlockCount < len(gens[0].files) {
return false, tsdb.SingleGenerationReason()
return false, tsdb.SingleGenerationReasonText
}
}
return true, ""
Expand Down
4 changes: 2 additions & 2 deletions tsdb/engine/tsm1/compact_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2487,7 +2487,7 @@ func TestDefaultPlanner_FullyCompacted_SmallSingleGeneration(t *testing.T) {
cp := tsm1.NewDefaultPlanner(fs, tsdb.DefaultCompactFullWriteColdDuration)

compacted, reason := cp.FullyCompacted()
require.Equal(t, reason, tsdb.SingleGenerationReason(), "fullyCompacted reason")
require.Equal(t, reason, tsdb.SingleGenerationReasonText, "fullyCompacted reason")
require.False(t, compacted, "is fully compacted")

_, cgLen := cp.PlanLevel(1)
Expand Down Expand Up @@ -2607,7 +2607,7 @@ func TestDefaultPlanner_FullyCompacted_LargeSingleGenerationUnderAggressiveBlock

cp := tsm1.NewDefaultPlanner(fs, tsdb.DefaultCompactFullWriteColdDuration)
compacted, reason := cp.FullyCompacted()
require.Equal(t, reason, tsdb.SingleGenerationReason(), "fullyCompacted reason")
require.Equal(t, reason, tsdb.SingleGenerationReasonText, "fullyCompacted reason")
require.False(t, compacted, "is fully compacted")

_, cgLen := cp.PlanLevel(1)
Expand Down

0 comments on commit fc6ca13

Please sign in to comment.