Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSDB Index reuses slices, adds pools #5630

Merged
merged 9 commits into from
Mar 17, 2022
Prev Previous commit
Next Next commit
reuse slices in tsdb benchmarks
  • Loading branch information
owen-d committed Mar 15, 2022
commit 523a2a89b38d7fa4020e1e80e31942b880825e78
6 changes: 4 additions & 2 deletions tools/tsdb/tsdb-map/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ func BenchmarkQuery_GetChunkRefs(b *testing.B) {
}
idx := tsdb.NewTSDBIndex(reader)
b.Run(bm.name, func(b *testing.B) {
refs := tsdb.ChunkRefsPool.Get()
for i := 0; i < b.N; i++ {
_, err := idx.GetChunkRefs(context.Background(), "fake", 0, math.MaxInt64, nil, bm.matchers...)
err := idx.GetChunkRefs(context.Background(), "fake", 0, math.MaxInt64, &refs, nil, bm.matchers...)
if err != nil {
panic(err)
}
Expand All @@ -101,14 +102,15 @@ func BenchmarkQuery_GetChunkRefsSharded(b *testing.B) {
shardFactor := 16

b.Run(bm.name, func(b *testing.B) {
refs := tsdb.ChunkRefsPool.Get()
for i := 0; i < b.N; i++ {
for j := 0; j < shardFactor; j++ {
shard := index.ShardAnnotation{
Shard: uint32(j),
Of: uint32(shardFactor),
}

_, err := idx.GetChunkRefs(context.Background(), "fake", 0, math.MaxInt64, &shard, bm.matchers...)
err := idx.GetChunkRefs(context.Background(), "fake", 0, math.MaxInt64, &refs, &shard, bm.matchers...)
if err != nil {
panic(err)
}
Expand Down