Skip to content

x/time: is not working on huge goroutine #39547

@Petelin

Description

@Petelin

i write such test code

func main() {
	l := rate.NewLimiter(100, 1)

	var runCounts = new(atomic.Int64)

	go func() {
		for {
			go func() {
				t := time.Now()
				ok := l.AllowN(t, 1)
				if ok {
					runCounts.Inc()
				}
			}()
		}
	}()

	<-time.After(time.Second * 5)
	fmt.Println(runCounts.Load())
	return
}

i expect result is around 501, but actually it may be a very loard number like 12694.

is there any miss understanding?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions