lib/mergeset: start assisted merge for file parts only if the number of file parts is bigger than maxFileParts

The maxFileParts usage has been accidentally removed in fa566c68a6

While at it, add Count suffix to *AssistedMerges counter names in order to make them less misleading.
Previously their names were falsely suggesting that these are gauges, which show the number of concurrently
executed assisted merges.
This commit is contained in:
Aliaksandr Valialkin 2024-01-24 15:07:40 +02:00
parent ac5b740750
commit 18df07e824
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB
2 changed files with 11 additions and 11 deletions

View file

@ -499,8 +499,8 @@ func writeStorageMetrics(w io.Writer, strg *storage.Storage) {
metrics.WriteCounterUint64(w, `vm_assisted_merges_total{type="storage/inmemory"}`, tm.InmemoryAssistedMerges)
metrics.WriteCounterUint64(w, `vm_assisted_merges_total{type="storage/small"}`, tm.SmallAssistedMerges)
metrics.WriteCounterUint64(w, `vm_assisted_merges_total{type="indexdb/inmemory"}`, idbm.InmemoryAssistedMerges)
metrics.WriteCounterUint64(w, `vm_assisted_merges_total{type="indexdb/file"}`, idbm.FileAssistedMerges)
metrics.WriteCounterUint64(w, `vm_assisted_merges_total{type="indexdb/inmemory"}`, idbm.InmemoryAssistedMergesCount)
metrics.WriteCounterUint64(w, `vm_assisted_merges_total{type="indexdb/file"}`, idbm.FileAssistedMergesCount)
metrics.WriteCounterUint64(w, `vm_indexdb_items_added_total`, idbm.ItemsAdded)
metrics.WriteCounterUint64(w, `vm_indexdb_items_added_size_bytes_total`, idbm.ItemsAddedSizeBytes)

View file

@ -110,8 +110,8 @@ type Table struct {
inmemoryItemsMerged uint64
fileItemsMerged uint64
inmemoryAssistedMerges uint64
fileAssistedMerges uint64
inmemoryAssistedMergesCount uint64
fileAssistedMergesCount uint64
itemsAdded uint64
itemsAddedSizeBytes uint64
@ -422,8 +422,8 @@ type TableMetrics struct {
InmemoryItemsMerged uint64
FileItemsMerged uint64
InmemoryAssistedMerges uint64
FileAssistedMerges uint64
InmemoryAssistedMergesCount uint64
FileAssistedMergesCount uint64
ItemsAdded uint64
ItemsAddedSizeBytes uint64
@ -473,8 +473,8 @@ func (tb *Table) UpdateMetrics(m *TableMetrics) {
m.InmemoryItemsMerged += atomic.LoadUint64(&tb.inmemoryItemsMerged)
m.FileItemsMerged += atomic.LoadUint64(&tb.fileItemsMerged)
m.InmemoryAssistedMerges += atomic.LoadUint64(&tb.inmemoryAssistedMerges)
m.FileAssistedMerges += atomic.LoadUint64(&tb.fileAssistedMerges)
m.InmemoryAssistedMergesCount += atomic.LoadUint64(&tb.inmemoryAssistedMergesCount)
m.FileAssistedMergesCount += atomic.LoadUint64(&tb.fileAssistedMergesCount)
m.ItemsAdded += atomic.LoadUint64(&tb.itemsAdded)
m.ItemsAddedSizeBytes += atomic.LoadUint64(&tb.itemsAddedSizeBytes)
@ -792,7 +792,7 @@ func (tb *Table) assistedMergeForInmemoryParts() {
return
}
atomic.AddUint64(&tb.inmemoryAssistedMerges, 1)
atomic.AddUint64(&tb.inmemoryAssistedMergesCount, 1)
maxOutBytes := tb.getMaxFilePartSize()
@ -812,13 +812,13 @@ func (tb *Table) assistedMergeForInmemoryParts() {
func (tb *Table) assistedMergeForFileParts() {
tb.partsLock.Lock()
needMerge := getNotInMergePartsCount(tb.fileParts) >= defaultPartsToMerge
needMerge := len(tb.fileParts) > maxFileParts && getNotInMergePartsCount(tb.fileParts) >= defaultPartsToMerge
tb.partsLock.Unlock()
if !needMerge {
return
}
atomic.AddUint64(&tb.fileAssistedMerges, 1)
atomic.AddUint64(&tb.fileAssistedMergesCount, 1)
err := tb.mergeExistingParts(false)
if err == nil {
return