-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bulk: Add metrics to bulk mem monitor for better visualisation
This change reworks how we want to use memory monitors for bulk operations. We have a single `bulkMonitor` which is a child of the root sql memory monitor. Each bulk operation will further create a child of the `bulkMonitor` which will be used to control memory growth of the bulk adder. A new class of metrics has been hooked up to the `bulkMonitor` which allows for visualization of total memory usage in the admin UI. Release note: None
- Loading branch information
1 parent
d183339
commit 4cfb2a3
Showing
4 changed files
with
88 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2019 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 bulk | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/util/metric" | ||
) | ||
|
||
// Metrics contains pointers to the metrics for | ||
// monitoring bulk operations. | ||
type Metrics struct { | ||
MaxBytesHist *metric.Histogram | ||
CurBytesCount *metric.Gauge | ||
} | ||
|
||
// MetricStruct implements the metrics.Struct interface. | ||
func (Metrics) MetricStruct() {} | ||
|
||
var _ metric.Struct = Metrics{} | ||
|
||
var ( | ||
metaMemMaxBytes = metric.Metadata{ | ||
Name: "sql.mem.bulk.max", | ||
Help: "Memory usage per sql statement for bulk operations", | ||
Measurement: "Memory", | ||
Unit: metric.Unit_BYTES, | ||
} | ||
metaMemCurBytes = metric.Metadata{ | ||
Name: "sql.mem.bulk.current", | ||
Help: "Current sql statement memory usage for bulk operations", | ||
Measurement: "Memory", | ||
Unit: metric.Unit_BYTES, | ||
} | ||
) | ||
|
||
// See pkg/sql/mem_metrics.go | ||
// log10int64times1000 = log10(math.MaxInt64) * 1000, rounded up somewhat | ||
const log10int64times1000 = 19 * 1000 | ||
|
||
// MakeBulkMetrics instantiates the metrics holder for bulk operation monitoring. | ||
func MakeBulkMetrics(histogramWindow time.Duration) Metrics { | ||
return Metrics{ | ||
MaxBytesHist: metric.NewHistogram(metaMemMaxBytes, histogramWindow, log10int64times1000, 3), | ||
CurBytesCount: metric.NewGauge(metaMemCurBytes), | ||
} | ||
} |
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