Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit f0b266a

Browse files
committed
Fix scheduler token bucket
1 parent d9077af commit f0b266a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

pkg/protocol/engine/congestioncontrol/scheduler/drr/basicbuffer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ func (b *BasicBuffer) ringInsert(v interface{}) *ring.Ring {
371371
func (b *BasicBuffer) waitTime(rate float64, block *blocks.Block) time.Duration {
372372
tokensRequired := float64(block.WorkScore()) - (b.tokenBucket + rate*time.Since(b.lastScheduleTime).Seconds())
373373

374-
return lo.Max(0, time.Duration(tokensRequired/rate))
374+
return lo.Max(0, time.Duration(tokensRequired/rate)*time.Second)
375375
}
376376

377377
func (b *BasicBuffer) updateTokenBucket(rate float64, tokenBucketSize float64) {

pkg/protocol/engine/congestioncontrol/scheduler/drr/scheduler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,11 @@ loop:
370370
case blockToSchedule = <-s.basicBuffer.blockChan:
371371
currentAPI := s.apiProvider.CommittedAPI()
372372
rate := currentAPI.ProtocolParameters().CongestionControlParameters().SchedulerRate
373-
if waitTime := s.basicBuffer.waitTime(float64(rate), blockToSchedule); waitTime > 0 {
373+
for waitTime := s.basicBuffer.waitTime(float64(rate), blockToSchedule); waitTime > 0; {
374374
timer := time.NewTimer(waitTime)
375375
<-timer.C
376376
}
377+
377378
s.basicBuffer.updateTokenBucket(float64(rate), float64(currentAPI.MaxBlockWork()))
378379

379380
s.scheduleBasicBlock(blockToSchedule)

0 commit comments

Comments
 (0)