Skip to content

Commit

Permalink
removed NextRun from stats
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumemichel committed Jan 31, 2025
1 parent 5bc192e commit 4e2d874
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The following emojis are used to highlight certain changes:

### Added

- `provider`: Added `LastRun` and `NextRun` stats to the Reprovider [#815](https://github.com/ipfs/boxo/pull/815)
- `provider`: Added `ReprovideInterval` and `LastRun` stats to the Reprovider [#815](https://github.com/ipfs/boxo/pull/815)


## [v0.27.2]
Expand Down
20 changes: 5 additions & 15 deletions provider/reprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ type reprovider struct {
noReprovideInFlight chan struct{}

maxReprovideBatchSize uint
acceleratedDHTClient bool

statLk sync.Mutex
totalProvides, lastReprovideBatchSize uint64
Expand Down Expand Up @@ -162,13 +161,6 @@ func Allowlist(allowlist verifcid.Allowlist) Option {
}
}

func AcceleratedDHTClient(v bool) Option {
return func(system *reprovider) error {
system.acceleratedDHTClient = v
return nil
}
}

func ReproviderInterval(duration time.Duration) Option {
return func(system *reprovider) error {
system.reprovideInterval = duration
Expand Down Expand Up @@ -366,15 +358,13 @@ func (s *reprovider) run() {
s.statLk.Lock()
s.avgProvideDuration = (totalProvideTime + dur) / (time.Duration(s.totalProvides) + time.Duration(len(keys)))
s.totalProvides += uint64(len(keys))
if s.acceleratedDHTClient {
s.lastRun = time.Now()
}

log.Debugf("finished providing of %d keys. It took %v with an average of %v per provide", len(keys), dur, recentAvgProvideDuration)

if performedReprovide {
s.lastReprovideBatchSize = uint64(len(keys))
s.lastReprovideDuration = dur
s.lastRun = time.Now()

s.statLk.Unlock()

Expand Down Expand Up @@ -549,9 +539,9 @@ func (s *reprovider) shouldReprovide() bool {
}

type ReproviderStats struct {
TotalProvides, LastReprovideBatchSize uint64
AvgProvideDuration, LastReprovideDuration time.Duration
LastRun, NextRun time.Time
TotalProvides, LastReprovideBatchSize uint64
ReprovideInterval, AvgProvideDuration, LastReprovideDuration time.Duration
LastRun time.Time
}

// Stat returns various stats about this provider system
Expand All @@ -561,10 +551,10 @@ func (s *reprovider) Stat() (ReproviderStats, error) {
return ReproviderStats{
TotalProvides: s.totalProvides,
LastReprovideBatchSize: s.lastReprovideBatchSize,
ReprovideInterval: s.reprovideInterval,
AvgProvideDuration: s.avgProvideDuration,
LastReprovideDuration: s.lastReprovideDuration,
LastRun: s.lastRun,
NextRun: s.lastRun.Add(DefaultReproviderInterval),
}, nil
}

Expand Down

0 comments on commit 4e2d874

Please sign in to comment.