Skip to content

Commit 0f27635

Browse files
committed
metrics: make the compaction kinds table more compact
Revert to using the horizontal orientation mode.
1 parent 83cd1d3 commit 0f27635

File tree

7 files changed

+78
-124
lines changed

7 files changed

+78
-124
lines changed

metrics.go

Lines changed: 22 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99
"iter"
1010
"math"
11+
"slices"
1112
"time"
1213
"unsafe"
1314

@@ -655,19 +656,9 @@ var (
655656
table.Bytes("sstsz", 6, table.AlignRight, func(m *LevelMetrics) uint64 { return m.TableBytesFlushed + m.TableBytesCompacted }),
656657
table.Bytes("blobsz", 6, table.AlignRight, func(m *LevelMetrics) uint64 { return m.BlobBytesFlushed + m.BlobBytesCompacted }),
657658
)
658-
compactionKindTable = table.Define[compactionKindsInfo](
659-
table.String("kind", 6, table.AlignRight, func(i compactionKindsInfo) string { return "count" }),
660-
table.Div(),
661-
table.String("default", 8, table.AlignRight, func(i compactionKindsInfo) string { return i.def }),
662-
table.String("delete", 8, table.AlignRight, func(i compactionKindsInfo) string { return i.delete }),
663-
table.String("elision", 8, table.AlignRight, func(i compactionKindsInfo) string { return i.elision }),
664-
table.String("copy", 8, table.AlignRight, func(i compactionKindsInfo) string { return i.copy }),
665-
table.String("move", 8, table.AlignRight, func(i compactionKindsInfo) string { return i.move }),
666-
table.String("read", 8, table.AlignRight, func(i compactionKindsInfo) string { return i.read }),
667-
table.String("tomb", 8, table.AlignRight, func(i compactionKindsInfo) string { return i.tombstone }),
668-
table.String("rewrite", 8, table.AlignRight, func(i compactionKindsInfo) string { return i.rewrite }),
669-
table.String("multi", 8, table.AlignRight, func(i compactionKindsInfo) string { return i.multilevel }),
670-
table.String("blob", 8, table.AlignRight, func(i compactionKindsInfo) string { return i.blob }),
659+
compactionKindTable = table.Define[pair[string, int64]](
660+
table.String("kind", 5, table.AlignRight, func(p pair[string, int64]) string { return p.k }),
661+
table.Count("count", 5, table.AlignRight, func(p pair[string, int64]) int64 { return p.v }),
671662
)
672663
commitPipelineInfoTableTopHeader = `COMMIT PIPELINE`
673664
commitPipelineInfoTableSubHeader = ` wals | memtables | ingestions`
@@ -761,19 +752,6 @@ var (
761752
)
762753
)
763754

764-
type compactionKindsInfo struct {
765-
def string
766-
delete string
767-
elision string
768-
copy string
769-
move string
770-
read string
771-
tombstone string
772-
rewrite string
773-
multilevel string
774-
blob string
775-
}
776-
777755
type commitPipelineInfo struct {
778756
files string
779757
written string
@@ -837,6 +815,11 @@ type keysInfo struct {
837815
rangeDels string
838816
}
839817

818+
type pair[k, v any] struct {
819+
k k
820+
v v
821+
}
822+
840823
// String pretty-prints the metrics.
841824
//
842825
// See testdata/metrics for an example.
@@ -883,21 +866,20 @@ func (m *Metrics) String() string {
883866
cur = compactionLevelMetricsTable.Render(cur, table.RenderOptions{}, compactionLevelIter)
884867
cur.Offset(-1, 0).WriteString("total")
885868

886-
compactionKindsContents := compactionKindsInfo{
887-
def: humanizeCount(m.Compact.DefaultCount).String(),
888-
delete: humanizeCount(m.Compact.DeleteOnlyCount).String(),
889-
elision: humanizeCount(m.Compact.ElisionOnlyCount).String(),
890-
copy: humanizeCount(m.Compact.CopyCount).String(),
891-
move: humanizeCount(m.Compact.MoveCount).String(),
892-
read: humanizeCount(m.Compact.ReadCount).String(),
893-
tombstone: humanizeCount(m.Compact.TombstoneDensityCount).String(),
894-
rewrite: humanizeCount(m.Compact.RewriteCount).String(),
895-
multilevel: humanizeCount(m.Compact.MultiLevelCount).String(),
896-
blob: humanizeCount(m.Compact.BlobFileRewriteCount).String(),
897-
}
898-
899869
cur = cur.NewlineReturn()
900-
cur = compactionKindTable.Render(cur, table.RenderOptions{}, oneItemIter(compactionKindsContents))
870+
compactionKindContents := []pair[string, int64]{
871+
{k: "default", v: m.Compact.DefaultCount},
872+
{k: "delete", v: m.Compact.DeleteOnlyCount},
873+
{k: "elision", v: m.Compact.ElisionOnlyCount},
874+
{k: "move", v: m.Compact.MoveCount},
875+
{k: "read", v: m.Compact.ReadCount},
876+
{k: "tomb", v: m.Compact.TombstoneDensityCount},
877+
{k: "rewrite", v: m.Compact.RewriteCount},
878+
{k: "copy", v: m.Compact.CopyCount},
879+
{k: "multi", v: m.Compact.MultiLevelCount},
880+
{k: "blob", v: m.Compact.BlobFileRewriteCount},
881+
}
882+
cur = compactionKindTable.Render(cur, table.RenderOptions{Orientation: table.Horizontally}, slices.Values(compactionKindContents))
901883
cur = cur.NewlineReturn()
902884

903885
commitPipelineInfoContents := commitPipelineInfo{

testdata/compaction/l0_to_lbase_compaction

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,8 @@ level | score ff cff | tables size | top in read | tables blob | ta
5555
5 | 0 0 0 | 0 0B | 0B 0B 0B | 0B 0B | 0 0B 0B
5656
total | 0 0.09 0.09 | 3 6MB | 0B 0B 0B | 0B 0B | 0 0B 0B
5757

58-
kind | default delete elision copy move read tomb rewrite multi blob
59-
-------+------------------------------------------------------------------------------------------
60-
count | 0 0 0 0 3 0 0 0 0 0
58+
kind | default delete elision move read tomb rewrite copy multi blob
59+
count | 0 0 0 3 0 0 0 0 0 0
6160

6261
COMMIT PIPELINE
6362
wals | memtables | ingestions

testdata/compaction/value_separation

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,8 @@ level | score ff cff | tables size | top in read | tables blob | ta
143143
5 | 0 0 0 | 1 848B | 0B 0B 0B | 0B 0B | 0 0B 0B
144144
total | 0 0.00 0.00 | 0 0B | 0B 0B 0B | 372B 84B | 1 899B 112B
145145

146-
kind | default delete elision copy move read tomb rewrite multi blob
147-
-------+------------------------------------------------------------------------------------------
148-
count | 1 0 0 0 5 0 0 0 0 0
146+
kind | default delete elision move read tomb rewrite copy multi blob
147+
count | 1 0 0 5 0 0 0 0 0 0
149148

150149
COMMIT PIPELINE
151150
wals | memtables | ingestions
@@ -415,9 +414,8 @@ level | score ff cff | tables size | top in read | tables blob | ta
415414
5 | 0 0 0 | 0 0B | 0B 0B 0B | 0B 0B | 0 0B 0B
416415
total | 0 0.00 0.00 | 0 0B | 0B 0B 0B | 310B 0B | 1 900B 0B
417416

418-
kind | default delete elision copy move read tomb rewrite multi blob
419-
-------+------------------------------------------------------------------------------------------
420-
count | 1 0 0 0 0 0 0 0 0 1
417+
kind | default delete elision move read tomb rewrite copy multi blob
418+
count | 1 0 0 0 0 0 0 0 0 1
421419

422420
COMMIT PIPELINE
423421
wals | memtables | ingestions

testdata/event_listener

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,8 @@ level | score ff cff | tables size | top in read | tables blob | ta
265265
5 | 0 0 0 | 0 0B | 0B 0B 0B | 0B 0B | 0 0B 0B
266266
total | 0 0.00 0.00 | 0 0B | 0B 0B 0B | 218B 0B | 1 755B 0B
267267

268-
kind | default delete elision copy move read tomb rewrite multi blob
269-
-------+------------------------------------------------------------------------------------------
270-
count | 1 0 0 0 0 0 0 0 0 0
268+
kind | default delete elision move read tomb rewrite copy multi blob
269+
count | 1 0 0 0 0 0 0 0 0 0
271270

272271
COMMIT PIPELINE
273272
wals | memtables | ingestions
@@ -402,9 +401,8 @@ level | score ff cff | tables size | top in read | tables blob | ta
402401
5 | 0 0 0 | 0 0B | 0B 0B 0B | 0B 0B | 0 0B 0B
403402
total | 0 0.00 0.00 | 0 0B | 0B 0B 0B | 218B 0B | 1 755B 0B
404403

405-
kind | default delete elision copy move read tomb rewrite multi blob
406-
-------+------------------------------------------------------------------------------------------
407-
count | 1 0 0 0 0 0 0 0 0 0
404+
kind | default delete elision move read tomb rewrite copy multi blob
405+
count | 1 0 0 0 0 0 0 0 0 0
408406

409407
COMMIT PIPELINE
410408
wals | memtables | ingestions

testdata/ingest

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ level | score ff cff | tables size | top in read | tables blob | ta
5454
5 | 0 0 0 | 0 0B | 0B 0B 0B | 0B 0B | 0 0B 0B
5555
total | 0 0.00 0.00 | 0 0B | 0B 0B 0B | 0B 0B | 0 0B 0B
5656

57-
kind | default delete elision copy move read tomb rewrite multi blob
58-
-------+------------------------------------------------------------------------------------------
59-
count | 0 0 0 0 0 0 0 0 0 0
57+
kind | default delete elision move read tomb rewrite copy multi blob
58+
count | 0 0 0 0 0 0 0 0 0 0
6059

6160
COMMIT PIPELINE
6261
wals | memtables | ingestions

0 commit comments

Comments
 (0)