diff --git a/internal/base/metrics.go b/internal/base/metrics.go index 4a7789a589..520edc3393 100644 --- a/internal/base/metrics.go +++ b/internal/base/metrics.go @@ -53,6 +53,15 @@ func (tm *ThroughputMetric) Rate() int64 { float64(time.Second)) } +// Utilization returns a percent [0, 1.0] indicating the percent of time +// work was performed. +func (tm *ThroughputMetric) Utilization() float64 { + if tm.WorkDuration == 0 { + return 0 + } + return float64(tm.WorkDuration) / float64(tm.WorkDuration+tm.IdleDuration) +} + // GaugeSampleMetric is used to measure a gauge value (e.g. queue length) by // accumulating samples of that gauge. type GaugeSampleMetric struct { diff --git a/replay/replay.go b/replay/replay.go index 48ac8f6164..f99c8baca2 100644 --- a/replay/replay.go +++ b/replay/replay.go @@ -199,6 +199,9 @@ func (m *Metrics) WriteBenchmarkString(name string, w io.Writer) error { {label: "EstimatedDebt/max", values: []benchfmt.Value{ {Value: float64(m.EstimatedDebt.Max()), Unit: "bytes"}, }}, + {label: "FlushUtilization", values: []benchfmt.Value{ + {Value: m.Final.Flush.WriteThroughput.Utilization(), Unit: "util"}, + }}, {label: "IngestedIntoL0", values: []benchfmt.Value{ {Value: float64(m.Ingest.BytesIntoL0), Unit: "bytes"}, }}, diff --git a/replay/replay_test.go b/replay/replay_test.go index 2c8eaa32e1..859b121bf2 100644 --- a/replay/replay_test.go +++ b/replay/replay_test.go @@ -415,6 +415,7 @@ func runListFiles(t *testing.T, fs vfs.FS, td *datadriven.TestData) string { func TestBenchmarkString(t *testing.T) { m := Metrics{ + Final: &pebble.Metrics{}, EstimatedDebt: SampledMetric{samples: []sample{{value: 5 << 25}}}, PaceDuration: time.Second / 4, QuiesceDuration: time.Second / 2, @@ -441,6 +442,7 @@ BenchmarkBenchmarkReplay/tpcc/DurationQuiescing 1 0.5 sec/op BenchmarkBenchmarkReplay/tpcc/DurationPaceDelay 1 0.25 sec/op BenchmarkBenchmarkReplay/tpcc/EstimatedDebt/mean 1 1.6777216e+08 bytes BenchmarkBenchmarkReplay/tpcc/EstimatedDebt/max 1 1.6777216e+08 bytes +BenchmarkBenchmarkReplay/tpcc/FlushUtilization 1 0 util BenchmarkBenchmarkReplay/tpcc/IngestedIntoL0 1 5.24288e+06 bytes BenchmarkBenchmarkReplay/tpcc/IngestWeightedByLevel 1 9.437184e+06 bytes BenchmarkBenchmarkReplay/tpcc/ReadAmp/mean 1 10 files