Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/time/rate: token bucket is not initially full #23482

Open
liggitt opened this issue Jan 19, 2018 · 3 comments
Open

x/time/rate: token bucket is not initially full #23482

liggitt opened this issue Jan 19, 2018 · 3 comments

Comments

@liggitt
Copy link
Contributor

@liggitt liggitt commented Jan 19, 2018

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

1.9.2

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/jliggitt/.gvm/pkgsets/go1.9.2/global"
GORACE=""
GOROOT="/Users/jliggitt/.gvm/gos/go1.9.2"
GOTOOLDIR="/Users/jliggitt/.gvm/gos/go1.9.2/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/lw/0m4r59zx3_b56vbmr2j0zkbr0000gn/T/go-build585916590=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

What did you do?

Created a new limiter, and attempted to take a token at t=0:

l := rate.NewLimiter(1, 1)
l.AllowN(time.Time{}, 1)

What did you expect to see?

AllowN(...any time..., 1) should succeed if the token bucket is initially full as documented.

What did you see instead?

AllowN returns false

It appears that the token bucket is not initially full.

The limiter depends on the elapsed time from the zero value of last to the value of now the first time AllowN is called being long enough to fill the bucket.

@gopherbot gopherbot added this to the Unreleased milestone Jan 19, 2018
@liggitt

This comment has been minimized.

Copy link
Contributor Author

@liggitt liggitt commented Jan 19, 2018

@bradfitz

This comment has been minimized.

Copy link
Contributor

@bradfitz bradfitz commented Jan 20, 2018

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Jan 20, 2018

Change https://golang.org/cl/88435 mentions this issue: rate: ensure token bucket is initially full

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.