@@ -653,59 +653,73 @@ func (m *Metrics) SafeFormat(w redact.SafePrinter, _ rune) {
653
653
654
654
var (
655
655
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
+ }()
682
688
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
+ }()
709
723
compactionKindTable = table .Define [* Metrics ](
710
724
table .String ("kind" , 5 , table .AlignRight , func (m * Metrics ) string { return "count" }),
711
725
table .Div (),
@@ -923,14 +937,14 @@ func (m *Metrics) String() string {
923
937
cur := wb .At (0 , 0 )
924
938
cur = cur .WriteString (levelMetricsTableTopHeader ).NewlineReturn ()
925
939
cur = levelMetricsTable .Render (cur , table.RenderOptions {
926
- HorizontalDividers : table .MakeHorizontalDividers (0 , manifest . NumLevels ),
940
+ HorizontalDividers : table .MakeHorizontalDividers (0 , - 1 ),
927
941
}, slices .Collect (m .LevelMetricsIter ())... )
928
942
cur = cur .NewlineReturn ()
929
943
930
944
// Compaction level metrics.
931
945
cur = cur .WriteString (levelCompactionMetricsTableTopHeader ).NewlineReturn ()
932
946
cur = compactionLevelMetricsTable .Render (cur , table.RenderOptions {
933
- HorizontalDividers : table .MakeHorizontalDividers (0 , manifest . NumLevels ),
947
+ HorizontalDividers : table .MakeHorizontalDividers (0 , - 1 ),
934
948
}, slices .Collect (m .LevelMetricsIter ())... )
935
949
936
950
cur = cur .NewlineReturn ()
0 commit comments