lib/storage: convert dedupsDuringMerge from uint64 to atomic.Uint64

This should simplify code maintenance by gradually converting to atomic.* types instead of calling atomic.* functions
on int and bool types.

See ea9e2b19a5
This commit is contained in:
Aliaksandr Valialkin 2024-02-23 22:51:48 +02:00
parent ea9e2b19a5
commit 0f1ea36dc8
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB
2 changed files with 3 additions and 3 deletions

View file

@ -171,12 +171,12 @@ func (b *Block) deduplicateSamplesDuringMerge() {
srcValues := b.values[b.nextIdx:]
timestamps, values := deduplicateSamplesDuringMerge(srcTimestamps, srcValues, dedupInterval)
dedups := len(srcTimestamps) - len(timestamps)
atomic.AddUint64(&dedupsDuringMerge, uint64(dedups))
dedupsDuringMerge.Add(uint64(dedups))
b.timestamps = b.timestamps[:b.nextIdx+len(timestamps)]
b.values = b.values[:b.nextIdx+len(values)]
}
var dedupsDuringMerge uint64
var dedupsDuringMerge atomic.Uint64
func (b *Block) rowsCount() int {
if len(b.values) == 0 {

View file

@ -545,7 +545,7 @@ func (m *Metrics) Reset() {
// UpdateMetrics updates m with metrics from s.
func (s *Storage) UpdateMetrics(m *Metrics) {
m.RowsAddedTotal = atomic.LoadUint64(&rowsAddedTotal)
m.DedupsDuringMerge = atomic.LoadUint64(&dedupsDuringMerge)
m.DedupsDuringMerge = dedupsDuringMerge.Load()
m.SnapshotsCount += uint64(s.mustGetSnapshotsCount())
m.TooSmallTimestampRows += atomic.LoadUint64(&s.tooSmallTimestampRows)