@@ -426,6 +426,20 @@ type CompactMetrics struct {
426426 // Duration records the cumulative duration of all compactions since the
427427 // database was opened.
428428 Duration time.Duration
429+ // BlobFileRewrite contains metrics for blob file rewrite compactions.
430+ BlobFileRewrite struct {
431+ // The total number of bytes read during blob file rewrite compactions.
432+ // This only counts blob value blocks (data blocks) that are read from
433+ // the input blob file. The index block is read but tracked as
434+ // blockkind.Metadata, not blockkind.BlobValue. As a result, BytesRead
435+ // can be smaller than BytesWritten.
436+ BytesRead int64
437+ // The total number of bytes written during blob file rewrite compactions.
438+ // This counts all bytes written to the output blob file, including blob
439+ // value blocks, index block, properties block, and footer. As a result,
440+ // BytesWritten can be larger than BytesRead.
441+ BytesWritten int64
442+ }
429443}
430444
431445// IngestMetrics contains metrics related to ingestions.
@@ -767,16 +781,21 @@ var (
767781 table .String ("tot" , 13 , table .AlignRight , func (i cgoMemInfo ) string { return i .memtablesTot }),
768782 )
769783 compactionInfoTableTopHeader = `COMPACTIONS`
784+ compactionInfoTableSubHeader = ` | blob rewrites`
770785 compactionInfoTable = table .Define [compactionMetricsInfo ](
771- table .String ("estimated debt" , 17 , table .AlignRight , func (i compactionMetricsInfo ) string { return i .estimatedDebt }),
786+ table .String ("est. debt" , 13 , table .AlignRight , func (i compactionMetricsInfo ) string { return i .estimatedDebt }),
787+ table .Div (),
788+ table .String ("in progress" , 13 , table .AlignRight , func (i compactionMetricsInfo ) string { return i .inProgress }),
789+ table .Div (),
790+ table .String ("cancelled" , 10 , table .AlignRight , func (i compactionMetricsInfo ) string { return i .cancelled }),
772791 table .Div (),
773- table .String ("in progress " , 17 , table .AlignRight , func (i compactionMetricsInfo ) string { return i . inProgress }),
792+ table .String ("failed " , 8 , table .AlignRight , func (i compactionMetricsInfo ) string { return fmt . Sprint ( i . failed ) }),
774793 table .Div (),
775- table .String ("cancelled " , 17 , table .AlignRight , func (i compactionMetricsInfo ) string { return i .cancelled }),
794+ table .String ("problem spans " , 16 , table .AlignRight , func (i compactionMetricsInfo ) string { return i .problemSpans }),
776795 table .Div (),
777- table .String ("failed " , 17 , table .AlignRight , func (i compactionMetricsInfo ) string { return fmt . Sprint ( i . failed ) }),
796+ table .String ("read " , 10 , table .AlignRight , func (i compactionMetricsInfo ) string { return i . blobFileRewriteBytesRead }),
778797 table .Div (),
779- table .String ("problem spans " , 18 , table .AlignRight , func (i compactionMetricsInfo ) string { return i .problemSpans }),
798+ table .String ("written " , 10 , table .AlignRight , func (i compactionMetricsInfo ) string { return i .blobFileRewriteBytesWritten }),
780799 )
781800 keysInfoTableTopHeader = `KEYS`
782801 keysInfoTable = table .Define [keysInfo ](
@@ -902,11 +921,13 @@ type cgoMemInfo struct {
902921}
903922
904923type compactionMetricsInfo struct {
905- estimatedDebt string
906- inProgress string
907- cancelled string
908- failed int64
909- problemSpans string
924+ estimatedDebt string
925+ inProgress string
926+ cancelled string
927+ failed int64
928+ problemSpans string
929+ blobFileRewriteBytesRead string
930+ blobFileRewriteBytesWritten string
910931}
911932
912933type keysInfo struct {
@@ -1119,10 +1140,13 @@ func (m *Metrics) String() string {
11191140 humanizeBytes (m .Compact .InProgressBytes )),
11201141 cancelled : fmt .Sprintf ("%s (%s)" , humanizeCount (m .Compact .CancelledCount ),
11211142 humanizeBytes (m .Compact .CancelledBytes )),
1122- failed : m .Compact .FailedCount ,
1123- problemSpans : fmt .Sprintf ("%d%s" , m .Compact .NumProblemSpans , ifNonZero (m .Compact .NumProblemSpans , "!!" )),
1143+ failed : m .Compact .FailedCount ,
1144+ problemSpans : fmt .Sprintf ("%d%s" , m .Compact .NumProblemSpans , ifNonZero (m .Compact .NumProblemSpans , "!!" )),
1145+ blobFileRewriteBytesRead : humanizeBytes (m .Compact .BlobFileRewrite .BytesRead ),
1146+ blobFileRewriteBytesWritten : humanizeBytes (m .Compact .BlobFileRewrite .BytesWritten ),
11241147 }
11251148 cur = cur .WriteString (compactionInfoTableTopHeader ).NewlineReturn ()
1149+ cur = cur .WriteString (compactionInfoTableSubHeader ).NewlineReturn ()
11261150 cur = compactionInfoTable .Render (cur , table.RenderOptions {}, compactionMetricsInfoContents )
11271151 cur = cur .NewlineReturn ()
11281152
0 commit comments