Skip to content

Commit

Permalink
enhance: [10kcp] Optimize GetLocalDiskSize and segment loader mutex
Browse files Browse the repository at this point in the history
Signed-off-by: bigsheeper <[email protected]>
  • Loading branch information
bigsheeper committed Dec 19, 2024
1 parent ecd5559 commit aad633c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
18 changes: 8 additions & 10 deletions internal/querynodev2/segments/disk_usage_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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()
}
}()
}
}
2 changes: 1 addition & 1 deletion internal/querynodev2/segments/segment_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit aad633c

Please sign in to comment.