Skip to content

Commit fad4ded

Browse files
committed
ratelimit fix
1 parent 0c26c0f commit fad4ded

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

internal/limiter/limiter.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030

3131
const (
3232
kbps2bpsMultiplier = 125 // kbps * 125 = bytes/s
33+
defaultBurstLimit = 16 * 1024
3334
)
3435

3536
type LimitTransport struct {
@@ -84,11 +85,9 @@ func (lc *limitChecker) Read(p []byte) (int, error) {
8485
if lc.rateLimit > 0 {
8586
if lc.limiter == nil {
8687

87-
// FIXME: setting burst limit to initial buffer size seems about right,
88-
// but is there a better value?
89-
lc.burstLimit = len(p)
88+
lc.burstLimit = defaultBurstLimit
9089

91-
slog.Debug("limiter: creating limiter", "burstlimit", lc.burstLimit, "ratelimit", lc.rateLimit)
90+
slog.Debug("limiter: creating limiter", "burstlimit", lc.burstLimit, "ratelimit", lc.rateLimit, "initial buf len", len(p))
9291

9392
// token bucket
9493
// - starts full and is refilled at the specified rate (tokens per second)

0 commit comments

Comments
 (0)