Skip to content

Commit c73e1b3

Browse files
committed
kvserver, storage: add bytes compressed/decompressed metrics
The motivation for these metrics is to enable estimating the CPU usage impact of switching to a stronger compression method (which applies only to L5/L6 data/value blocks). Epic: none Release note: None
1 parent a053744 commit c73e1b3

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

pkg/kv/kvserver/metrics.go

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,54 @@ storage.initial_stats_complete becomes true.
12361236
Measurement: "Ratio",
12371237
Unit: metric.Unit_CONST,
12381238
}
1239+
metaBytesCompressedL5Data = metric.Metadata{
1240+
Name: "storage.bytes-compressed.l5.data",
1241+
Help: "Total number of logical bytes compressed for L5 data blocks.",
1242+
Measurement: "Bytes",
1243+
Unit: metric.Unit_BYTES,
1244+
}
1245+
metaBytesDecompressedL5Data = metric.Metadata{
1246+
Name: "storage.bytes-decompressed.l5.data",
1247+
Help: "Total number of logical bytes decompressed for L5 data blocks.",
1248+
Measurement: "Bytes",
1249+
Unit: metric.Unit_BYTES,
1250+
}
1251+
metaBytesCompressedL5Values = metric.Metadata{
1252+
Name: "storage.bytes-compressed.l5.values",
1253+
Help: "Total number of logical bytes compressed for L5 value blocks.",
1254+
Measurement: "Bytes",
1255+
Unit: metric.Unit_BYTES,
1256+
}
1257+
metaBytesDecompressedL5Values = metric.Metadata{
1258+
Name: "storage.bytes-decompressed.l5.values",
1259+
Help: "Total number of logical bytes decompressed for L5 value blocks.",
1260+
Measurement: "Bytes",
1261+
Unit: metric.Unit_BYTES,
1262+
}
1263+
metaBytesCompressedL6Data = metric.Metadata{
1264+
Name: "storage.bytes-compressed.l6.data",
1265+
Help: "Total number of logical bytes compressed for L6 data blocks.",
1266+
Measurement: "Bytes",
1267+
Unit: metric.Unit_BYTES,
1268+
}
1269+
metaBytesDecompressedL6Data = metric.Metadata{
1270+
Name: "storage.bytes-decompressed.l6.data",
1271+
Help: "Total number of logical bytes decompressed for L6 data blocks.",
1272+
Measurement: "Bytes",
1273+
Unit: metric.Unit_BYTES,
1274+
}
1275+
metaBytesCompressedL6Values = metric.Metadata{
1276+
Name: "storage.bytes-compressed.l6.values",
1277+
Help: "Total number of logical bytes compressed for L6 value blocks.",
1278+
Measurement: "Bytes",
1279+
Unit: metric.Unit_BYTES,
1280+
}
1281+
metaBytesDecompressedL6Values = metric.Metadata{
1282+
Name: "storage.bytes-decompressed.l6.values",
1283+
Help: "Total number of logical bytes decompressed for L6 value blocks.",
1284+
Measurement: "Bytes",
1285+
Unit: metric.Unit_BYTES,
1286+
}
12391287
)
12401288

12411289
var (
@@ -3115,6 +3163,13 @@ type StoreMetrics struct {
31153163
CompressionUnknownBytes *metric.Gauge
31163164
CompressionOverallCR *metric.GaugeFloat64
31173165

3166+
BytesCompressed, BytesDecompressed struct {
3167+
L5, L6 struct {
3168+
Values *metric.Counter
3169+
Data *metric.Counter
3170+
}
3171+
}
3172+
31183173
categoryIterMetrics pebbleCategoryIterMetricsContainer
31193174
categoryDiskWriteMetrics pebbleCategoryDiskWriteMetricsContainer
31203175
ValueSeparationBytesReferenced *metric.Gauge
@@ -3872,6 +3927,8 @@ func newStoreMetrics(histogramWindow time.Duration) *StoreMetrics {
38723927
CompressionUnknownBytes: metric.NewGauge(metaCompressionUnknownBytes),
38733928
CompressionOverallCR: metric.NewGaugeFloat64(metaCompressionOverallCR),
38743929

3930+
// BytesCompressed, BytesDecompressed are initialized below.
3931+
38753932
categoryDiskWriteMetrics: pebbleCategoryDiskWriteMetricsContainer{
38763933
registry: storeRegistry,
38773934
},
@@ -4212,6 +4269,16 @@ func newStoreMetrics(histogramWindow time.Duration) *StoreMetrics {
42124269
ClosedTimestampPolicyChange: metric.NewCounter(metaClosedTimestampPolicyChange),
42134270
ClosedTimestampLatencyInfoMissing: metric.NewCounter(metaClosedTimestampLatencyInfoMissing),
42144271
}
4272+
4273+
sm.BytesCompressed.L5.Data = metric.NewCounter(metaBytesCompressedL5Data)
4274+
sm.BytesCompressed.L5.Values = metric.NewCounter(metaBytesCompressedL5Values)
4275+
sm.BytesCompressed.L6.Data = metric.NewCounter(metaBytesCompressedL6Data)
4276+
sm.BytesCompressed.L6.Values = metric.NewCounter(metaBytesCompressedL6Values)
4277+
sm.BytesDecompressed.L5.Data = metric.NewCounter(metaBytesDecompressedL5Data)
4278+
sm.BytesDecompressed.L5.Values = metric.NewCounter(metaBytesDecompressedL5Values)
4279+
sm.BytesDecompressed.L6.Data = metric.NewCounter(metaBytesDecompressedL6Data)
4280+
sm.BytesDecompressed.L6.Values = metric.NewCounter(metaBytesDecompressedL6Values)
4281+
42154282
sm.categoryIterMetrics.init(storeRegistry)
42164283

42174284
storeRegistry.AddMetricStruct(sm)
@@ -4378,6 +4445,15 @@ func (sm *StoreMetrics) updateEngineMetrics(m storage.Metrics) {
43784445
// ratio; we estimate it from the data we do have.
43794446
sm.CompressionOverallCR.Update(overall.CompressionRatio())
43804447

4448+
sm.BytesCompressed.L5.Values.Update(int64(m.CompressionCounters.LogicalBytesCompressed.L5.ValueBlocks))
4449+
sm.BytesCompressed.L5.Data.Update(int64(m.CompressionCounters.LogicalBytesCompressed.L5.DataBlocks))
4450+
sm.BytesCompressed.L6.Values.Update(int64(m.CompressionCounters.LogicalBytesCompressed.L6.ValueBlocks))
4451+
sm.BytesCompressed.L6.Data.Update(int64(m.CompressionCounters.LogicalBytesCompressed.L6.DataBlocks))
4452+
sm.BytesDecompressed.L5.Values.Update(int64(m.CompressionCounters.LogicalBytesDecompressed.L5.ValueBlocks))
4453+
sm.BytesDecompressed.L5.Data.Update(int64(m.CompressionCounters.LogicalBytesDecompressed.L5.DataBlocks))
4454+
sm.BytesDecompressed.L6.Values.Update(int64(m.CompressionCounters.LogicalBytesDecompressed.L6.ValueBlocks))
4455+
sm.BytesDecompressed.L6.Data.Update(int64(m.CompressionCounters.LogicalBytesDecompressed.L6.DataBlocks))
4456+
43814457
sm.categoryIterMetrics.update(m.CategoryStats)
43824458
sm.categoryDiskWriteMetrics.update(m.DiskWriteStats)
43834459

0 commit comments

Comments
 (0)