Skip to content

Commit be70bab

Browse files
authored
Introduce a new stat which indicates a bleve index's convergence (#2152)
`index_bgthreads_active` indicates whether the background routines that maintain the index are busy doing some work. This means that the index hasn't converged to a steady state and there could be potential file segment merges or in-memory segment flushes still remaining. This stat is beneficial for the application layer to get better insight as to whether the index is doing some background work (which can have implications on the system's resource utilisation) or not.
1 parent 469974e commit be70bab

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

index/scorch/scorch.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,17 @@ func (s *Scorch) StatsMap() map[string]interface{} {
658658
m["num_persister_nap_merger_break"] = m["TotPersisterMergerNapBreak"]
659659
m["total_compaction_written_bytes"] = m["TotFileMergeWrittenBytes"]
660660

661+
// the bool stat `index_bgthreads_active` indicates whether the background routines
662+
// (which are responsible for the index to attain a steady state) are still
663+
// doing some work.
664+
if rootEpoch, ok := m["CurRootEpoch"].(uint64); ok {
665+
if lastMergedEpoch, ok := m["LastMergedEpoch"].(uint64); ok {
666+
if lastPersistedEpoch, ok := m["LastPersistedEpoch"].(uint64); ok {
667+
m["index_bgthreads_active"] = !(lastMergedEpoch == rootEpoch && lastPersistedEpoch == rootEpoch)
668+
}
669+
}
670+
}
671+
661672
// calculate the aggregate of all the segment's field stats
662673
aggFieldStats := newFieldStats()
663674
for _, segmentSnapshot := range indexSnapshot.Segments() {

0 commit comments

Comments
 (0)