forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bulk: add histograms to ingestion performance stats
This change adds two histograms to the IngestionPerformanceStats. A histogram that tracks the batch wait, and one that tracks the SST data size. This change also adds a count for the number of ssts that are ingested as write batches. Release note: None
- Loading branch information
1 parent
9cc17d7
commit 34eb57a
Showing
9 changed files
with
316 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright 2023 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package bulkpb | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"time" | ||
|
||
"github.com/codahale/hdrhistogram" | ||
) | ||
|
||
type HistogramDataType int | ||
|
||
const ( | ||
HistogramDataTypeLatency HistogramDataType = iota | ||
HistogramDataTypeBytes | ||
) | ||
|
||
const mb = 1 << 20 | ||
|
||
// String implements the stringer interface. | ||
func (h *HistogramData) String() string { | ||
var b strings.Builder | ||
hist := hdrhistogram.Import(&hdrhistogram.Snapshot{ | ||
LowestTrackableValue: h.LowestTrackableValue, | ||
HighestTrackableValue: h.HighestTrackableValue, | ||
SignificantFigures: h.SignificantFigures, | ||
Counts: h.Counts, | ||
}) | ||
|
||
stringify := func(denominator float64) { | ||
b.WriteString(fmt.Sprintf("min: %.6f\n", float64(hist.Min())/denominator)) | ||
b.WriteString(fmt.Sprintf("max: %.6f\n", float64(hist.Max())/denominator)) | ||
b.WriteString(fmt.Sprintf("p5: %.6f\n", float64(hist.ValueAtQuantile(5))/denominator)) | ||
b.WriteString(fmt.Sprintf("p50: %.6f\n", float64(hist.ValueAtQuantile(50))/denominator)) | ||
b.WriteString(fmt.Sprintf("p90: %.6f\n", float64(hist.ValueAtQuantile(90))/denominator)) | ||
b.WriteString(fmt.Sprintf("p99: %.6f\n", float64(hist.ValueAtQuantile(99))/denominator)) | ||
b.WriteString(fmt.Sprintf("p99_9: %.6f\n", float64(hist.ValueAtQuantile(99.9))/denominator)) | ||
b.WriteString(fmt.Sprintf("mean: %.6f\n", float32(hist.Mean())/float32(denominator))) | ||
b.WriteString(fmt.Sprintf("count: %d\n", hist.TotalCount())) | ||
} | ||
|
||
switch h.DataType { | ||
case HistogramDataTypeLatency: | ||
stringify(float64(time.Second)) | ||
case HistogramDataTypeBytes: | ||
stringify(float64(mb)) | ||
} | ||
|
||
return b.String() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.