(b *testing.B)
| 1275 | } |
| 1276 | |
| 1277 | func BenchmarkCompactionFromOOOHead(b *testing.B) { |
| 1278 | dir := b.TempDir() |
| 1279 | totalSeries := 100000 |
| 1280 | totalSamples := 100 |
| 1281 | for labelNames := 1; labelNames < totalSeries; labelNames *= 10 { |
| 1282 | labelValues := totalSeries / labelNames |
| 1283 | b.Run(fmt.Sprintf("labelnames=%d,labelvalues=%d", labelNames, labelValues), func(b *testing.B) { |
| 1284 | chunkDir := b.TempDir() |
| 1285 | opts := DefaultHeadOptions() |
| 1286 | opts.ChunkRange = 1000 |
| 1287 | opts.ChunkDirRoot = chunkDir |
| 1288 | opts.OutOfOrderTimeWindow.Store(int64(totalSamples)) |
| 1289 | h, err := NewHead(nil, nil, nil, nil, opts, nil) |
| 1290 | require.NoError(b, err) |
| 1291 | for ln := 0; ln < labelNames; ln++ { |
| 1292 | app := h.Appender(context.Background()) |
| 1293 | for lv := range labelValues { |
| 1294 | lbls := labels.FromStrings(strconv.Itoa(ln), fmt.Sprintf("%d%s%d", lv, postingsBenchSuffix, ln)) |
| 1295 | _, err = app.Append(0, lbls, int64(totalSamples), 0) |
| 1296 | require.NoError(b, err) |
| 1297 | for ts := range totalSamples { |
| 1298 | _, err = app.Append(0, lbls, int64(ts), float64(ts)) |
| 1299 | require.NoError(b, err) |
| 1300 | } |
| 1301 | } |
| 1302 | require.NoError(b, app.Commit()) |
| 1303 | } |
| 1304 | |
| 1305 | b.ResetTimer() |
| 1306 | b.ReportAllocs() |
| 1307 | for i := 0; b.Loop(); i++ { |
| 1308 | oooHead, err := NewOOOCompactionHead(context.TODO(), h) |
| 1309 | require.NoError(b, err) |
| 1310 | createBlockFromOOOHead(b, filepath.Join(dir, fmt.Sprintf("%d-%d", i, labelNames)), oooHead) |
| 1311 | } |
| 1312 | h.Close() |
| 1313 | }) |
| 1314 | } |
| 1315 | } |
| 1316 | |
| 1317 | // TestDisableAutoCompactions checks that we can |
| 1318 | // disable and enable the auto compaction. |
nothing calls this directly
no test coverage detected
searching dependent graphs…