mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/storage: replace the remaining atomic.* functions with atomic.* types for the sake of consistency
See ea9e2b19a5
This commit is contained in:
parent
b3d9d36fb3
commit
55f1f24e62
3 changed files with 15 additions and 8 deletions
|
@ -2611,8 +2611,12 @@ func (s *Storage) mustOpenIndexDBTables(path string) (next, curr, prev *indexDB)
|
|||
var indexDBTableNameRegexp = regexp.MustCompile("^[0-9A-F]{16}$")
|
||||
|
||||
func nextIndexDBTableName() string {
|
||||
n := atomic.AddUint64(&indexDBTableIdx, 1)
|
||||
n := indexDBTableIdx.Add(1)
|
||||
return fmt.Sprintf("%016X", n)
|
||||
}
|
||||
|
||||
var indexDBTableIdx = uint64(time.Now().UnixNano())
|
||||
var indexDBTableIdx = func() *atomic.Uint64 {
|
||||
var x atomic.Uint64
|
||||
x.Store(uint64(time.Now().UnixNano()))
|
||||
return &x
|
||||
}()
|
||||
|
|
|
@ -25,7 +25,7 @@ func benchmarkStorageAddRows(b *testing.B, rowsPerBatch int) {
|
|||
}
|
||||
}()
|
||||
|
||||
var globalOffset uint64
|
||||
var globalOffset atomic.Uint64
|
||||
|
||||
b.SetBytes(int64(rowsPerBatch))
|
||||
b.ReportAllocs()
|
||||
|
@ -39,7 +39,7 @@ func benchmarkStorageAddRows(b *testing.B, rowsPerBatch int) {
|
|||
{[]byte("instance"), []byte("1.2.3.4")},
|
||||
}
|
||||
for pb.Next() {
|
||||
offset := int(atomic.AddUint64(&globalOffset, uint64(rowsPerBatch)))
|
||||
offset := int(globalOffset.Add(uint64(rowsPerBatch)))
|
||||
for i := 0; i < rowsPerBatch; i++ {
|
||||
mr := &mrs[i]
|
||||
mr.MetricNameRaw = mn.marshalRaw(mr.MetricNameRaw[:0])
|
||||
|
|
|
@ -69,8 +69,11 @@ func createBenchTable(b *testing.B, path string, startTimestamp int64, rowsPerIn
|
|||
strg := newTestStorage()
|
||||
tb := mustOpenTable(path, strg)
|
||||
|
||||
insertsCount := uint64((rowsCount + rowsPerInsert - 1) / rowsPerInsert)
|
||||
timestamp := uint64(startTimestamp)
|
||||
var insertsCount atomic.Int64
|
||||
insertsCount.Store(int64((rowsCount + rowsPerInsert - 1) / rowsPerInsert))
|
||||
|
||||
var timestamp atomic.Uint64
|
||||
timestamp.Store(uint64(startTimestamp))
|
||||
|
||||
var wg sync.WaitGroup
|
||||
for k := 0; k < cgroup.AvailableCPUs(); k++ {
|
||||
|
@ -79,9 +82,9 @@ func createBenchTable(b *testing.B, path string, startTimestamp int64, rowsPerIn
|
|||
rng := rand.New(rand.NewSource(int64(n)))
|
||||
rows := make([]rawRow, rowsPerInsert)
|
||||
value := float64(100)
|
||||
for int(atomic.AddUint64(&insertsCount, ^uint64(0))) >= 0 {
|
||||
for insertsCount.Add(-1) >= 0 {
|
||||
for j := 0; j < rowsPerInsert; j++ {
|
||||
ts := atomic.AddUint64(×tamp, uint64(10+rng.Int63n(2)))
|
||||
ts := timestamp.Add(uint64(10 + rng.Int63n(2)))
|
||||
value += float64(int(rng.NormFloat64() * 5))
|
||||
|
||||
r := &rows[j]
|
||||
|
|
Loading…
Reference in a new issue