From aad633ce8cf8351449cb0a07a7c2c962800c614e Mon Sep 17 00:00:00 2001 From: bigsheeper Date: Thu, 19 Dec 2024 21:20:24 +0800 Subject: [PATCH 1/2] enhance: [10kcp] Optimize GetLocalDiskSize and segment loader mutex Signed-off-by: bigsheeper --- .../querynodev2/segments/disk_usage_fetcher.go | 18 ++++++++---------- .../querynodev2/segments/segment_loader.go | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/internal/querynodev2/segments/disk_usage_fetcher.go b/internal/querynodev2/segments/disk_usage_fetcher.go index 0bb9060af7f9f..4a31722b6d25a 100644 --- a/internal/querynodev2/segments/disk_usage_fetcher.go +++ b/internal/querynodev2/segments/disk_usage_fetcher.go @@ -56,7 +56,7 @@ func (d *diskUsageFetcher) fetch() { d.diskUsage.Store(diskUsage) metrics.QueryNodeDiskUsedSize.WithLabelValues(fmt.Sprint(paramtable.GetNodeID())).Set(float64(diskUsage) / 1024 / 1024) // in MB log.Ctx(d.ctx).WithRateGroup("diskUsageFetcher", 1, 300). - RatedInfo(300, "querynode disk usage", zap.Int64("size", diskUsage), zap.Int64("nodeID", paramtable.GetNodeID())) + Info("querynode disk usage", zap.Int64("size", diskUsage), zap.Int64("nodeID", paramtable.GetNodeID())) } func (d *diskUsageFetcher) Start() { @@ -65,14 +65,12 @@ func (d *diskUsageFetcher) Start() { interval := paramtable.Get().QueryNodeCfg.DiskSizeFetchInterval.GetAsDuration(time.Second) ticker := time.NewTicker(interval) defer ticker.Stop() - go func() { - for { - select { - case <-d.ctx.Done(): - return - case <-ticker.C: - d.fetch() - } + for { + select { + case <-d.ctx.Done(): + return + case <-ticker.C: + d.fetch() } - }() + } } diff --git a/internal/querynodev2/segments/segment_loader.go b/internal/querynodev2/segments/segment_loader.go index 4815bc426818f..8b107a01e6047 100644 --- a/internal/querynodev2/segments/segment_loader.go +++ b/internal/querynodev2/segments/segment_loader.go @@ -567,7 +567,7 @@ func NewLoader( log.Info("SegmentLoader created", zap.Int("ioPoolSize", ioPoolSize)) duf := NewDiskUsageFetcher(ctx) - duf.Start() + go duf.Start() loader := &segmentLoader{ manager: manager, From 35a59b90f14105fee2f2197d730264faa324ec1a Mon Sep 17 00:00:00 2001 From: bigsheeper Date: Thu, 19 Dec 2024 21:21:37 +0800 Subject: [PATCH 2/2] fix Signed-off-by: bigsheeper --- internal/querynodev2/segments/disk_usage_fetcher.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/querynodev2/segments/disk_usage_fetcher.go b/internal/querynodev2/segments/disk_usage_fetcher.go index 4a31722b6d25a..5bd41ee17585d 100644 --- a/internal/querynodev2/segments/disk_usage_fetcher.go +++ b/internal/querynodev2/segments/disk_usage_fetcher.go @@ -56,7 +56,7 @@ func (d *diskUsageFetcher) fetch() { d.diskUsage.Store(diskUsage) metrics.QueryNodeDiskUsedSize.WithLabelValues(fmt.Sprint(paramtable.GetNodeID())).Set(float64(diskUsage) / 1024 / 1024) // in MB log.Ctx(d.ctx).WithRateGroup("diskUsageFetcher", 1, 300). - Info("querynode disk usage", zap.Int64("size", diskUsage), zap.Int64("nodeID", paramtable.GetNodeID())) + RatedInfo(300, "querynode disk usage", zap.Int64("size", diskUsage), zap.Int64("nodeID", paramtable.GetNodeID())) } func (d *diskUsageFetcher) Start() {