@@ -418,6 +418,20 @@ type CompactMetrics struct {
418418 // Duration records the cumulative duration of all compactions since the
419419 // database was opened.
420420 Duration time.Duration
421+ // BlobFileRewrite contains metrics for blob file rewrite compactions.
422+ BlobFileRewrite struct {
423+ // The total number of bytes read during blob file rewrite compactions.
424+ // This only counts blob value blocks (data blocks) that are read from
425+ // the input blob file. The index block is read but tracked as
426+ // blockkind.Metadata, not blockkind.BlobValue. As a result, BytesRead
427+ // can be smaller than BytesWritten.
428+ BytesRead int64
429+ // The total number of bytes written during blob file rewrite compactions.
430+ // This counts all bytes written to the output blob file, including blob
431+ // value blocks, index block, properties block, and footer. As a result,
432+ // BytesWritten can be larger than BytesRead.
433+ BytesWritten int64
434+ }
421435}
422436
423437// IngestMetrics contains metrics related to ingestions.
@@ -759,16 +773,21 @@ var (
759773 table .String ("tot" , 13 , table .AlignRight , func (i cgoMemInfo ) string { return i .memtablesTot }),
760774 )
761775 compactionInfoTableTopHeader = `COMPACTIONS`
776+ compactionInfoTableSubHeader = ` | blob rewrites`
762777 compactionInfoTable = table .Define [compactionMetricsInfo ](
763- table .String ("estimated debt" , 17 , table .AlignRight , func (i compactionMetricsInfo ) string { return i .estimatedDebt }),
778+ table .String ("est. debt" , 13 , table .AlignRight , func (i compactionMetricsInfo ) string { return i .estimatedDebt }),
779+ table .Div (),
780+ table .String ("in progress" , 13 , table .AlignRight , func (i compactionMetricsInfo ) string { return i .inProgress }),
781+ table .Div (),
782+ table .String ("cancelled" , 10 , table .AlignRight , func (i compactionMetricsInfo ) string { return i .cancelled }),
764783 table .Div (),
765- table .String ("in progress " , 17 , table .AlignRight , func (i compactionMetricsInfo ) string { return i . inProgress }),
784+ table .String ("failed " , 8 , table .AlignRight , func (i compactionMetricsInfo ) string { return fmt . Sprint ( i . failed ) }),
766785 table .Div (),
767- table .String ("cancelled " , 17 , table .AlignRight , func (i compactionMetricsInfo ) string { return i .cancelled }),
786+ table .String ("problem spans " , 16 , table .AlignRight , func (i compactionMetricsInfo ) string { return i .problemSpans }),
768787 table .Div (),
769- table .String ("failed " , 17 , table .AlignRight , func (i compactionMetricsInfo ) string { return fmt . Sprint ( i . failed ) }),
788+ table .String ("read " , 10 , table .AlignRight , func (i compactionMetricsInfo ) string { return i . blobFileRewriteBytesRead }),
770789 table .Div (),
771- table .String ("problem spans " , 18 , table .AlignRight , func (i compactionMetricsInfo ) string { return i .problemSpans }),
790+ table .String ("written " , 10 , table .AlignRight , func (i compactionMetricsInfo ) string { return i .blobFileRewriteBytesWritten }),
772791 )
773792 keysInfoTableTopHeader = `KEYS`
774793 keysInfoTable = table .Define [keysInfo ](
@@ -883,11 +902,13 @@ type cgoMemInfo struct {
883902}
884903
885904type compactionMetricsInfo struct {
886- estimatedDebt string
887- inProgress string
888- cancelled string
889- failed int64
890- problemSpans string
905+ estimatedDebt string
906+ inProgress string
907+ cancelled string
908+ failed int64
909+ problemSpans string
910+ blobFileRewriteBytesRead string
911+ blobFileRewriteBytesWritten string
891912}
892913
893914type keysInfo struct {
@@ -1072,10 +1093,13 @@ func (m *Metrics) String() string {
10721093 humanizeBytes (m .Compact .InProgressBytes )),
10731094 cancelled : fmt .Sprintf ("%s (%s)" , humanizeCount (m .Compact .CancelledCount ),
10741095 humanizeBytes (m .Compact .CancelledBytes )),
1075- failed : m .Compact .FailedCount ,
1076- problemSpans : fmt .Sprintf ("%d%s" , m .Compact .NumProblemSpans , ifNonZero (m .Compact .NumProblemSpans , "!!" )),
1096+ failed : m .Compact .FailedCount ,
1097+ problemSpans : fmt .Sprintf ("%d%s" , m .Compact .NumProblemSpans , ifNonZero (m .Compact .NumProblemSpans , "!!" )),
1098+ blobFileRewriteBytesRead : humanizeBytes (m .Compact .BlobFileRewrite .BytesRead ),
1099+ blobFileRewriteBytesWritten : humanizeBytes (m .Compact .BlobFileRewrite .BytesWritten ),
10771100 }
10781101 cur = cur .WriteString (compactionInfoTableTopHeader ).NewlineReturn ()
1102+ cur = cur .WriteString (compactionInfoTableSubHeader ).NewlineReturn ()
10791103 cur = compactionInfoTable .Render (cur , table.RenderOptions {}, compactionMetricsInfoContents )
10801104 cur = cur .NewlineReturn ()
10811105
0 commit comments