Skip to content

Commit

Permalink
Add metric for number of tables being compacted (dgraph-io#1554)
Browse files Browse the repository at this point in the history
Add an expVar to expose the metric for number of tables being compacted at
any point of time.
  • Loading branch information
ahsanbarkati committed Oct 3, 2020
1 parent 599363b commit 0b10bb0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions levels.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,10 @@ func (s *levelsController) compactBuildTables(
topTables := cd.top
botTables := cd.bot

numTables := int64(len(topTables) + len(botTables))
y.NumCompactionTables.Add(numTables)
defer y.NumCompactionTables.Add(-numTables)

// Check overlap of the top level with the levels which are not being
// compacted in this compaction.
hasOverlap := s.checkOverlap(cd.allTables(), cd.nextLevel.level+1)
Expand Down
3 changes: 3 additions & 0 deletions y/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ var (
NumBlockedPuts *expvar.Int
// NumMemtableGets is number of memtable gets
NumMemtableGets *expvar.Int
// NumCompactionTables is the number of tables being compacted
NumCompactionTables *expvar.Int
)

// These variables are global and have cumulative values for all kv stores.
Expand All @@ -65,4 +67,5 @@ func init() {
LSMSize = expvar.NewMap("badger_v2_lsm_size_bytes")
VlogSize = expvar.NewMap("badger_v2_vlog_size_bytes")
PendingWrites = expvar.NewMap("badger_v2_pending_writes_total")
NumCompactionTables = expvar.NewInt("badger_v2_compactions_current")
}

0 comments on commit 0b10bb0

Please sign in to comment.