I have to add that I had a problem with multiple sleeps (which creates a runtime.timer struct), because of the amount of newly generated structures to be collected on the next GC.
Which is why https://github.com/ironsmile/nedomi/blob/master/utils/throttle/timers.go was wrote. Before this pool, pprof was being topped by GC in cpu usage and runtime.timer in allocated objects count. It's important to note that my use case was throttling 3-5+ thousand connections which a sleep every 10ms+. And there are always thousand of timers running. So my advice is if the tons of go timers can be reused ... to reuse them :D. If you do https://github.com/golang/go/issues/11513 is a mandatory read. # go test -bench BenchmarkParallelSlee* -benchmem -benchtime 2m > BenchmarkParallelSleepWithSTD-4 3000 59055109 > ns/op 1280003 B/op 20000 allocs/op > BenchmarkParallelSleepWithPooledTimer-4 3000 61768205 > ns/op 5113 B/op 40 allocs/op > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.