diff --git a/lib/mergeset/table.go b/lib/mergeset/table.go index b6bf3f470..ddd0bac40 100644 --- a/lib/mergeset/table.go +++ b/lib/mergeset/table.go @@ -126,7 +126,7 @@ type Table struct { } type rawItemsShards struct { - shardIdx uint64 + shardIdx uint32 // shards reduce lock contention when adding rows on multi-CPU systems. shards []rawItemsShard @@ -144,9 +144,9 @@ func (riss *rawItemsShards) init() { } func (riss *rawItemsShards) addItems(tb *Table, items [][]byte) error { - n := atomic.AddUint64(&riss.shardIdx, 1) + n := atomic.AddUint32(&riss.shardIdx, 1) shards := riss.shards - idx := n % uint64(len(shards)) + idx := n % uint32(len(shards)) shard := &shards[idx] return shard.addItems(tb, items) } diff --git a/lib/storage/partition.go b/lib/storage/partition.go index 07bb23ca2..4bf6f833b 100644 --- a/lib/storage/partition.go +++ b/lib/storage/partition.go @@ -437,7 +437,7 @@ func (pt *partition) AddRows(rows []rawRow) { } type rawRowsShards struct { - shardIdx uint64 + shardIdx uint32 // Shards reduce lock contention when adding rows on multi-CPU systems. shards []rawRowsShard @@ -448,9 +448,9 @@ func (rrss *rawRowsShards) init() { } func (rrss *rawRowsShards) addRows(pt *partition, rows []rawRow) { - n := atomic.AddUint64(&rrss.shardIdx, 1) + n := atomic.AddUint32(&rrss.shardIdx, 1) shards := rrss.shards - idx := n % uint64(len(shards)) + idx := n % uint32(len(shards)) shard := &shards[idx] shard.addRows(pt, rows) }