Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Anis Elleuch committed Jan 2, 2024
1 parent 2658499 commit 5f20b78
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
8 changes: 4 additions & 4 deletions cmd/data-scanner-metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func (p *scannerMetrics) lastMinuteActions(a lifecycle.Action) AccElem {
return val
}

// addCycleEvent updates the current cycle metrics.
// bucketScanStarted updates the cycle count of the given bucket.
func (p *scannerMetrics) bucketScanStarted(bucket string, cycle uint32) {
p.cycleInfoMu.Lock()
defer p.cycleInfoMu.Unlock()
Expand Down Expand Up @@ -279,7 +279,7 @@ type currentScannerCycle struct {
current uint64
ongoing bool
started time.Time
cycleCompleted []time.Time
cycleCompleted []time.Time // Last 10 completed cycles
}

// clone returns a clone.
Expand All @@ -288,8 +288,8 @@ func (z currentScannerCycle) clone() currentScannerCycle {
return z
}

// getCycle returns the current cycle metrics.
// If not nil, the returned value can safely be modified.
// getCycles returns the current cycle metrics for all buckets
// If not nil, the returned result can safely be modified.
func (p *scannerMetrics) getCycles() map[string]currentScannerCycle {
p.cycleInfoMu.Lock()
defer p.cycleInfoMu.Unlock()
Expand Down
14 changes: 8 additions & 6 deletions cmd/erasure.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,12 +445,14 @@ func (er erasureObjects) nsScanner(ctx context.Context, scanMgr *bucketsScanMgr,
}
}()

// Restrict parallelism for disk usage scanner
// upto GOMAXPROCS if GOMAXPROCS is < len(disks)
cpuGuard := make(chan struct{}, runtime.GOMAXPROCS(0))

scanWg := sync.WaitGroup{}
scanID := er.poolIndex<<16 | er.setIndex
var (
// Restrict parallelism for disk usage scanner
// upto GOMAXPROCS if GOMAXPROCS is < len(disks)
cpuGuard = make(chan struct{}, runtime.GOMAXPROCS(0))

scanWg sync.WaitGroup
scanID = er.poolIndex<<16 | er.setIndex
)

for bucket := range scanMgr.getBucketCh(scanID) {
select {
Expand Down

0 comments on commit 5f20b78

Please sign in to comment.