Skip to content

Commit

Permalink
replay: surface FlushUtilization metric
Browse files Browse the repository at this point in the history
During compaction benchmarking, compute flush utilization.
  • Loading branch information
jbowens committed Jun 6, 2023
1 parent 52cd0f8 commit 5f9fad0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/base/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions replay/replay.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
}},
Expand Down
2 changes: 2 additions & 0 deletions replay/replay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit 5f9fad0

Please sign in to comment.