Skip to content

Commit 844c201

Browse files
committed
metrics: hide empty level metrics
Hide rows that have all zeros in the level and compaction metrics. Also, use `Lx` instead of just `x` for the level.
1 parent 5abc279 commit 844c201

File tree

7 files changed

+183
-446
lines changed

7 files changed

+183
-446
lines changed

metrics.go

Lines changed: 68 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -653,59 +653,73 @@ func (m *Metrics) SafeFormat(w redact.SafePrinter, _ rune) {
653653

654654
var (
655655
levelMetricsTableTopHeader = `LSM | vtables | value sep | | ingested | amp`
656-
levelMetricsTable = table.Define[*LevelMetrics](
657-
table.StringWithTupleIndex("level", 5, table.AlignRight, func(tupleIndex int, m *LevelMetrics) string {
658-
if tupleIndex == manifest.NumLevels {
659-
return "total"
660-
}
661-
return fmt.Sprintf("%d", tupleIndex)
662-
}),
663-
table.Bytes("size", 10, table.AlignRight, func(m *LevelMetrics) uint64 { return uint64(m.TablesSize) + m.EstimatedReferencesSize }),
664-
table.Div(),
665-
table.Count("tables", 6, table.AlignRight, func(m *LevelMetrics) int64 { return m.TablesCount }),
666-
table.Bytes("size", 5, table.AlignRight, func(m *LevelMetrics) int64 { return m.TablesSize }),
667-
table.Div(),
668-
table.Count("count", 6, table.AlignRight, func(m *LevelMetrics) uint64 { return m.VirtualTablesCount }),
669-
table.Count("size", 5, table.AlignRight, func(m *LevelMetrics) uint64 { return m.VirtualTablesSize }),
670-
table.Div(),
671-
table.Bytes("refsz", 6, table.AlignRight, func(m *LevelMetrics) uint64 { return m.EstimatedReferencesSize }),
672-
table.Bytes("valblk", 6, table.AlignRight, func(m *LevelMetrics) uint64 { return m.Additional.ValueBlocksSize }),
673-
table.Div(),
674-
table.Bytes("in", 6, table.AlignRight, func(m *LevelMetrics) uint64 { return m.TableBytesIn }),
675-
table.Div(),
676-
table.Count("tables", 6, table.AlignRight, func(m *LevelMetrics) uint64 { return m.TablesIngested }),
677-
table.Bytes("size", 5, table.AlignRight, func(m *LevelMetrics) uint64 { return m.TableBytesIngested }),
678-
table.Div(),
679-
table.Int("r", 3, table.AlignRight, func(m *LevelMetrics) int { return int(m.Sublevels) }),
680-
table.Float("w", 5, table.AlignRight, func(m *LevelMetrics) float64 { return m.WriteAmp() }),
681-
)
656+
levelMetricsTable = func() table.Layout[*LevelMetrics] {
657+
def := table.Define[*LevelMetrics](
658+
table.StringWithTupleIndex("level", 5, table.AlignRight, func(tupleIndex int, m *LevelMetrics) string {
659+
if tupleIndex == manifest.NumLevels {
660+
return "total"
661+
}
662+
return fmt.Sprintf("L%d", tupleIndex)
663+
}),
664+
table.Bytes("size", 10, table.AlignRight, func(m *LevelMetrics) uint64 { return uint64(m.TablesSize) + m.EstimatedReferencesSize }),
665+
table.Div(),
666+
table.Count("tables", 6, table.AlignRight, func(m *LevelMetrics) int64 { return m.TablesCount }),
667+
table.Bytes("size", 5, table.AlignRight, func(m *LevelMetrics) int64 { return m.TablesSize }),
668+
table.Div(),
669+
table.Count("count", 6, table.AlignRight, func(m *LevelMetrics) uint64 { return m.VirtualTablesCount }),
670+
table.Count("size", 5, table.AlignRight, func(m *LevelMetrics) uint64 { return m.VirtualTablesSize }),
671+
table.Div(),
672+
table.Bytes("refsz", 6, table.AlignRight, func(m *LevelMetrics) uint64 { return m.EstimatedReferencesSize }),
673+
table.Bytes("valblk", 6, table.AlignRight, func(m *LevelMetrics) uint64 { return m.Additional.ValueBlocksSize }),
674+
table.Div(),
675+
table.Bytes("in", 6, table.AlignRight, func(m *LevelMetrics) uint64 { return m.TableBytesIn }),
676+
table.Div(),
677+
table.Count("tables", 6, table.AlignRight, func(m *LevelMetrics) uint64 { return m.TablesIngested }),
678+
table.Bytes("size", 5, table.AlignRight, func(m *LevelMetrics) uint64 { return m.TableBytesIngested }),
679+
table.Div(),
680+
table.Int("r", 3, table.AlignRight, func(m *LevelMetrics) int { return int(m.Sublevels) }),
681+
table.Float("w", 5, table.AlignRight, func(m *LevelMetrics) float64 { return m.WriteAmp() }),
682+
)
683+
def.FilterFn = func(tupleIndex int, m *LevelMetrics) (passed bool) {
684+
return m.TablesCount != 0 || m.VirtualTablesCount != 0 || m.TableBytesIn != 0 || m.TablesIngested != 0
685+
}
686+
return def
687+
}()
682688
levelCompactionMetricsTableTopHeader = `COMPACTIONS | moved | multilevel | read | written`
683-
compactionLevelMetricsTable = table.Define[*LevelMetrics](
684-
table.StringWithTupleIndex("level", 5, table.AlignRight, func(tupleIndex int, m *LevelMetrics) string {
685-
if tupleIndex == manifest.NumLevels {
686-
return "total"
687-
}
688-
return fmt.Sprintf("%d", tupleIndex)
689-
}),
690-
table.Div(),
691-
table.Float("score", 5, table.AlignRight, func(m *LevelMetrics) float64 { return m.Score }),
692-
table.Float("ff", 5, table.AlignRight, func(m *LevelMetrics) float64 { return m.FillFactor }),
693-
table.Float("cff", 5, table.AlignRight, func(m *LevelMetrics) float64 { return m.CompensatedFillFactor }),
694-
table.Div(),
695-
table.Count("tables", 6, table.AlignRight, func(m *LevelMetrics) uint64 { return m.TablesMoved }),
696-
table.Bytes("size", 5, table.AlignRight, func(m *LevelMetrics) uint64 { return m.TableBytesMoved }),
697-
table.Div(),
698-
table.Bytes("top", 5, table.AlignRight, func(m *LevelMetrics) uint64 { return m.MultiLevel.TableBytesInTop }),
699-
table.Bytes("in", 5, table.AlignRight, func(m *LevelMetrics) uint64 { return m.MultiLevel.TableBytesIn }),
700-
table.Bytes("read", 5, table.AlignRight, func(m *LevelMetrics) uint64 { return m.MultiLevel.TableBytesRead }),
701-
table.Div(),
702-
table.Bytes("tables", 6, table.AlignRight, func(m *LevelMetrics) uint64 { return m.TableBytesRead }),
703-
table.Bytes("blob", 5, table.AlignRight, func(m *LevelMetrics) uint64 { return m.BlobBytesRead }),
704-
table.Div(),
705-
table.Count("tables", 6, table.AlignRight, func(m *LevelMetrics) uint64 { return m.TablesFlushed + m.TablesCompacted }),
706-
table.Bytes("sstsz", 6, table.AlignRight, func(m *LevelMetrics) uint64 { return m.TableBytesFlushed + m.TableBytesCompacted }),
707-
table.Bytes("blobsz", 6, table.AlignRight, func(m *LevelMetrics) uint64 { return m.BlobBytesFlushed + m.BlobBytesCompacted }),
708-
)
689+
compactionLevelMetricsTable = func() table.Layout[*LevelMetrics] {
690+
def := table.Define[*LevelMetrics](
691+
table.StringWithTupleIndex("level", 5, table.AlignRight, func(tupleIndex int, m *LevelMetrics) string {
692+
if tupleIndex == manifest.NumLevels {
693+
return "total"
694+
}
695+
return fmt.Sprintf("L%d", tupleIndex)
696+
}),
697+
table.Div(),
698+
table.Float("score", 5, table.AlignRight, func(m *LevelMetrics) float64 { return m.Score }),
699+
table.Float("ff", 5, table.AlignRight, func(m *LevelMetrics) float64 { return m.FillFactor }),
700+
table.Float("cff", 5, table.AlignRight, func(m *LevelMetrics) float64 { return m.CompensatedFillFactor }),
701+
table.Div(),
702+
table.Count("tables", 6, table.AlignRight, func(m *LevelMetrics) uint64 { return m.TablesMoved }),
703+
table.Bytes("size", 5, table.AlignRight, func(m *LevelMetrics) uint64 { return m.TableBytesMoved }),
704+
table.Div(),
705+
table.Bytes("top", 5, table.AlignRight, func(m *LevelMetrics) uint64 { return m.MultiLevel.TableBytesInTop }),
706+
table.Bytes("in", 5, table.AlignRight, func(m *LevelMetrics) uint64 { return m.MultiLevel.TableBytesIn }),
707+
table.Bytes("read", 5, table.AlignRight, func(m *LevelMetrics) uint64 { return m.MultiLevel.TableBytesRead }),
708+
table.Div(),
709+
table.Bytes("tables", 6, table.AlignRight, func(m *LevelMetrics) uint64 { return m.TableBytesRead }),
710+
table.Bytes("blob", 5, table.AlignRight, func(m *LevelMetrics) uint64 { return m.BlobBytesRead }),
711+
table.Div(),
712+
table.Count("tables", 6, table.AlignRight, func(m *LevelMetrics) uint64 { return m.TablesFlushed + m.TablesCompacted }),
713+
table.Bytes("sstsz", 6, table.AlignRight, func(m *LevelMetrics) uint64 { return m.TableBytesFlushed + m.TableBytesCompacted }),
714+
table.Bytes("blobsz", 6, table.AlignRight, func(m *LevelMetrics) uint64 { return m.BlobBytesFlushed + m.BlobBytesCompacted }),
715+
)
716+
def.FilterFn = func(tupleIndex int, m *LevelMetrics) (passed bool) {
717+
return !math.IsNaN(m.Score) || m.FillFactor != 0 || m.TablesMoved != 0 || m.MultiLevel.TableBytesInTop != 0 ||
718+
m.MultiLevel.TableBytesIn != 0 || m.MultiLevel.TableBytesRead != 0 || m.BlobBytesRead != 0 ||
719+
m.TablesFlushed != 0 || m.TablesCompacted != 0 || m.BlobBytesFlushed != 0 || m.BlobBytesCompacted != 0
720+
}
721+
return def
722+
}()
709723
compactionKindTable = table.Define[*Metrics](
710724
table.String("kind", 5, table.AlignRight, func(m *Metrics) string { return "count" }),
711725
table.Div(),
@@ -923,14 +937,14 @@ func (m *Metrics) String() string {
923937
cur := wb.At(0, 0)
924938
cur = cur.WriteString(levelMetricsTableTopHeader).NewlineReturn()
925939
cur = levelMetricsTable.Render(cur, table.RenderOptions{
926-
HorizontalDividers: table.MakeHorizontalDividers(0, manifest.NumLevels),
940+
HorizontalDividers: table.MakeHorizontalDividers(0, -1),
927941
}, slices.Collect(m.LevelMetricsIter())...)
928942
cur = cur.NewlineReturn()
929943

930944
// Compaction level metrics.
931945
cur = cur.WriteString(levelCompactionMetricsTableTopHeader).NewlineReturn()
932946
cur = compactionLevelMetricsTable.Render(cur, table.RenderOptions{
933-
HorizontalDividers: table.MakeHorizontalDividers(0, manifest.NumLevels),
947+
HorizontalDividers: table.MakeHorizontalDividers(0, -1),
934948
}, slices.Collect(m.LevelMetricsIter())...)
935949

936950
cur = cur.NewlineReturn()

testdata/compaction/l0_to_lbase_compaction

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,16 @@ metrics
3636
LSM | vtables | value sep | | ingested | amp
3737
level size | tables size | count size | refsz valblk | in | tables size | r w
3838
-----------------+--------------+--------------+---------------+--------+--------------+----------
39-
0 0B | 0 0B | 0 0 | 0B 0B | 4.5MB | 0 0B | 0 1.32
40-
1 0B | 0 0B | 0 0 | 0B 0B | 0B | 0 0B | 0 0
41-
2 0B | 0 0B | 0 0 | 0B 0B | 0B | 0 0B | 0 0
42-
3 0B | 0 0B | 0 0 | 0B 0B | 0B | 0 0B | 0 0
43-
4 0B | 0 0B | 0 0 | 0B 0B | 0B | 0 0B | 0 0
44-
5 0B | 0 0B | 0 0 | 0B 0B | 0B | 0 0B | 0 0
45-
6 6MB | 3 6MB | 0 0 | 0B 0B | 0B | 0 0B | 1 0
39+
L0 0B | 0 0B | 0 0 | 0B 0B | 4.5MB | 0 0B | 0 1.32
40+
L6 6MB | 3 6MB | 0 0 | 0B 0B | 0B | 0 0B | 1 0
4641
-----------------+--------------+--------------+---------------+--------+--------------+----------
4742
total 6MB | 3 6MB | 0 0 | 0B 0B | 4.5MB | 0 0B | 1 2.32
4843

4944
COMPACTIONS | moved | multilevel | read | written
5045
level | score ff cff | tables size | top in read | tables blob | tables sstsz blobsz
5146
------+-------------------+--------------+-------------------+--------------+---------------------
52-
0 | - 0 0 | 0 0B | 0B 0B 0B | 0B 0B | 3 6MB 0B
53-
1 | - 0 0 | 0 0B | 0B 0B 0B | 0B 0B | 0 0B 0B
54-
2 | - 0 0 | 0 0B | 0B 0B 0B | 0B 0B | 0 0B 0B
55-
3 | - 0 0 | 0 0B | 0B 0B 0B | 0B 0B | 0 0B 0B
56-
4 | - 0 0 | 0 0B | 0B 0B 0B | 0B 0B | 0 0B 0B
57-
5 | - 0 0 | 0 0B | 0B 0B 0B | 0B 0B | 0 0B 0B
58-
6 | - 0.09 0.09 | 3 6MB | 0B 0B 0B | 0B 0B | 0 0B 0B
47+
L0 | - 0 0 | 0 0B | 0B 0B 0B | 0B 0B | 3 6MB 0B
48+
L6 | - 0.09 0.09 | 3 6MB | 0B 0B 0B | 0B 0B | 0 0B 0B
5949
------+-------------------+--------------+-------------------+--------------+---------------------
6050
total | - - - | 3 6MB | 0B 0B 0B | 0B 0B | 3 10MB 0B
6151

testdata/compaction/value_separation

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -124,26 +124,21 @@ metrics
124124
LSM | vtables | value sep | | ingested | amp
125125
level size | tables size | count size | refsz valblk | in | tables size | r w
126126
-----------------+--------------+--------------+---------------+--------+--------------+----------
127-
0 0B | 0 0B | 0 0 | 0B 0B | 41B | 0 0B | 0 23.24
128-
1 0B | 0 0B | 0 0 | 0B 0B | 0B | 0 0B | 0 0
129-
2 0B | 0 0B | 0 0 | 0B 0B | 0B | 0 0B | 0 0
130-
3 0B | 0 0B | 0 0 | 0B 0B | 0B | 0 0B | 0 0
131-
4 0B | 0 0B | 0 0 | 0B 0B | 0B | 0 0B | 0 0
132-
5 0B | 0 0B | 0 0 | 0B 0B | 0B | 0 0B | 0 0
133-
6 916B | 1 804B | 0 0 | 112B 0B | 753B | 0 0B | 1 1.22
127+
L0 0B | 0 0B | 0 0 | 0B 0B | 41B | 0 0B | 0 23.24
128+
L6 916B | 1 804B | 0 0 | 112B 0B | 753B | 0 0B | 1 1.22
134129
-----------------+--------------+--------------+---------------+--------+--------------+----------
135130
total 916B | 1 804B | 0 0 | 112B 0B | 41B | 0 0B | 1 46.59
136131

137132
COMPACTIONS | moved | multilevel | read | written
138133
level | score ff cff | tables size | top in read | tables blob | tables sstsz blobsz
139134
------+-------------------+--------------+-------------------+--------------+---------------------
140-
0 | - 0 0 | 0 0B | 0B 0B 0B | 0B 0B | 1 753B 200B
141-
1 | - 0 0 | 1 753B | 0B 0B 0B | 0B 0B | 0 0B 0B
142-
2 | - 0 0 | 1 753B | 0B 0B 0B | 0B 0B | 0 0B 0B
143-
3 | - 0 0 | 1 753B | 0B 0B 0B | 0B 0B | 0 0B 0B
144-
4 | - 0 0 | 1 753B | 0B 0B 0B | 0B 0B | 0 0B 0B
145-
5 | - 0 0 | 1 753B | 0B 0B 0B | 0B 0B | 0 0B 0B
146-
6 | - 0.00 0.00 | 0 0B | 0B 0B 0B | 372B 84B | 1 804B 112B
135+
L0 | - 0 0 | 0 0B | 0B 0B 0B | 0B 0B | 1 753B 200B
136+
L1 | - 0 0 | 1 753B | 0B 0B 0B | 0B 0B | 0 0B 0B
137+
L2 | - 0 0 | 1 753B | 0B 0B 0B | 0B 0B | 0 0B 0B
138+
L3 | - 0 0 | 1 753B | 0B 0B 0B | 0B 0B | 0 0B 0B
139+
L4 | - 0 0 | 1 753B | 0B 0B 0B | 0B 0B | 0 0B 0B
140+
L5 | - 0 0 | 1 753B | 0B 0B 0B | 0B 0B | 0 0B 0B
141+
L6 | - 0.00 0.00 | 0 0B | 0B 0B 0B | 372B 84B | 1 804B 112B
147142
------+-------------------+--------------+-------------------+--------------+---------------------
148143
total | - - - | 5 3.7KB | 0B 0B 0B | 372B 84B | 2 1.6KB 312B
149144

@@ -402,26 +397,16 @@ metrics
402397
LSM | vtables | value sep | | ingested | amp
403398
level size | tables size | count size | refsz valblk | in | tables size | r w
404399
-----------------+--------------+--------------+---------------+--------+--------------+----------
405-
0 0B | 0 0B | 0 0 | 0B 0B | 156B | 0 0B | 0 13.33
406-
1 0B | 0 0B | 0 0 | 0B 0B | 0B | 0 0B | 0 0
407-
2 0B | 0 0B | 0 0 | 0B 0B | 0B | 0 0B | 0 0
408-
3 0B | 0 0B | 0 0 | 0B 0B | 0B | 0 0B | 0 0
409-
4 0B | 0 0B | 0 0 | 0B 0B | 0B | 0 0B | 0 0
410-
5 0B | 0 0B | 0 0 | 0B 0B | 0B | 0 0B | 0 0
411-
6 1KB | 1 805B | 0 0 | 232B 0B | 1.5KB | 0 0B | 1 0.51
400+
L0 0B | 0 0B | 0 0 | 0B 0B | 156B | 0 0B | 0 13.33
401+
L6 1KB | 1 805B | 0 0 | 232B 0B | 1.5KB | 0 0B | 1 0.51
412402
-----------------+--------------+--------------+---------------+--------+--------------+----------
413403
total 1KB | 1 805B | 0 0 | 232B 0B | 156B | 0 0B | 1 19.49
414404

415405
COMPACTIONS | moved | multilevel | read | written
416406
level | score ff cff | tables size | top in read | tables blob | tables sstsz blobsz
417407
------+-------------------+--------------+-------------------+--------------+---------------------
418-
0 | - 0 0 | 0 0B | 0B 0B 0B | 0B 0B | 2 1.5KB 502B
419-
1 | - 0 0 | 0 0B | 0B 0B 0B | 0B 0B | 0 0B 0B
420-
2 | - 0 0 | 0 0B | 0B 0B 0B | 0B 0B | 0 0B 0B
421-
3 | - 0 0 | 0 0B | 0B 0B 0B | 0B 0B | 0 0B 0B
422-
4 | - 0 0 | 0 0B | 0B 0B 0B | 0B 0B | 0 0B 0B
423-
5 | - 0 0 | 0 0B | 0B 0B 0B | 0B 0B | 0 0B 0B
424-
6 | - 0.00 0.00 | 0 0B | 0B 0B 0B | 310B 0B | 1 805B 0B
408+
L0 | - 0 0 | 0 0B | 0B 0B 0B | 0B 0B | 2 1.5KB 502B
409+
L6 | - 0.00 0.00 | 0 0B | 0B 0B 0B | 310B 0B | 1 805B 0B
425410
------+-------------------+--------------+-------------------+--------------+---------------------
426411
total | - - - | 0 0B | 0B 0B 0B | 310B 0B | 3 2.5KB 502B
427412

0 commit comments

Comments
 (0)