MCPcopy
hub / github.com/prometheus/prometheus / BenchmarkCompactionFromOOOHead

Function BenchmarkCompactionFromOOOHead

tsdb/compact_test.go:1277–1315  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

1275}
1276
1277func 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.

Callers

nothing calls this directly

Calls 11

AppenderMethod · 0.95
CloseMethod · 0.95
FromStringsFunction · 0.92
DefaultHeadOptionsFunction · 0.85
NewHeadFunction · 0.85
NewOOOCompactionHeadFunction · 0.85
createBlockFromOOOHeadFunction · 0.85
RunMethod · 0.65
StoreMethod · 0.65
AppendMethod · 0.65
CommitMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…