mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-01-20 07:19:17 +01:00
lib/storage: replace the remaining atomic.* functions with atomic.* types for the sake of consistency
See ea9e2b19a5
This commit is contained in:
parent
a1baf25c2e
commit
6fd6d4c2de
@ -46,7 +46,7 @@ func BenchmarkIndexDBAddTSIDs(b *testing.B) {
|
||||
|
||||
const recordsPerLoop = 1e3
|
||||
|
||||
var goroutineID uint32
|
||||
var goroutineID atomic.Uint32
|
||||
|
||||
b.ReportAllocs()
|
||||
b.SetBytes(recordsPerLoop)
|
||||
@ -54,7 +54,7 @@ func BenchmarkIndexDBAddTSIDs(b *testing.B) {
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
var mn MetricName
|
||||
var genTSID generationTSID
|
||||
mn.AccountID = atomic.AddUint32(&goroutineID, 1)
|
||||
mn.AccountID = goroutineID.Add(1)
|
||||
|
||||
// The most common tags.
|
||||
mn.Tags = []Tag{
|
||||
|
@ -2762,8 +2762,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++ {
|
||||
mn.AccountID = uint32(i)
|
||||
mn.ProjectID = uint32(i % 3)
|
||||
|
@ -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 New Issue
Block a user