From 40fe656de98e44e461eaadd553468411e6cf2e92 Mon Sep 17 00:00:00 2001 From: XuanYang-cn Date: Thu, 28 Nov 2024 10:38:37 +0800 Subject: [PATCH] enhance: compaction performance by remove paramtable get (#37882) pr: #37163 Signed-off-by: yangxuan --- .../datanode/compaction/segment_writer.go | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/internal/datanode/compaction/segment_writer.go b/internal/datanode/compaction/segment_writer.go index a5cd9548ef..c2a60cf966 100644 --- a/internal/datanode/compaction/segment_writer.go +++ b/internal/datanode/compaction/segment_writer.go @@ -287,13 +287,14 @@ type SegmentWriter struct { tsFrom typeutil.Timestamp tsTo typeutil.Timestamp - pkstats *storage.PrimaryKeyStats - segmentID int64 - partitionID int64 - collectionID int64 - sch *schemapb.CollectionSchema - rowCount *atomic.Int64 - syncedSize *atomic.Int64 + pkstats *storage.PrimaryKeyStats + segmentID int64 + partitionID int64 + collectionID int64 + sch *schemapb.CollectionSchema + rowCount *atomic.Int64 + syncedSize *atomic.Int64 + maxBinlogSize uint64 } func (w *SegmentWriter) GetRowNum() int64 { @@ -341,12 +342,12 @@ func (w *SegmentWriter) Finish() (*storage.Blob, error) { } func (w *SegmentWriter) IsFull() bool { - return w.writer.WrittenMemorySize() > paramtable.Get().DataNodeCfg.BinLogMaxSize.GetAsUint64() + return w.writer.WrittenMemorySize() > w.maxBinlogSize } func (w *SegmentWriter) FlushAndIsFull() bool { w.writer.Flush() - return w.writer.WrittenMemorySize() > paramtable.Get().DataNodeCfg.BinLogMaxSize.GetAsUint64() + return w.writer.WrittenMemorySize() > w.maxBinlogSize } func (w *SegmentWriter) IsEmpty() bool { @@ -418,13 +419,14 @@ func NewSegmentWriter(sch *schemapb.CollectionSchema, maxCount int64, segID, par tsFrom: math.MaxUint64, tsTo: 0, - pkstats: stats, - sch: sch, - segmentID: segID, - partitionID: partID, - collectionID: collID, - rowCount: atomic.NewInt64(0), - syncedSize: atomic.NewInt64(0), + pkstats: stats, + sch: sch, + segmentID: segID, + partitionID: partID, + collectionID: collID, + rowCount: atomic.NewInt64(0), + syncedSize: atomic.NewInt64(0), + maxBinlogSize: paramtable.Get().DataNodeCfg.BinLogMaxSize.GetAsUint64(), } return &segWriter, nil