While investigating CPU with pprof on our services that uses the mentioned watcher, we found that massive CPU usage was caused by runtime.siftdownTimer.
The source of this large amount of generated Tickers was this place naming.go:79 time.Tick
Moving that to time.After fixes the issue.
We cannot create Tick before loop and reuse that, since timeToSleep is dynamic.
While investigating CPU with pprof on our services that uses the mentioned watcher, we found that massive CPU usage was caused by
runtime.siftdownTimer
. The source of this large amount of generated Tickers was this placenaming.go:79 time.Tick
Moving that to time.After fixes the issue. We cannot create Tick before loop and reuse that, since timeToSleep is dynamic.
See: https://forum.golangbridge.org/t/runtime-siftdowntimer-consuming-60-of-the-cpu/3773
Signed-off-by: Bartek Plotka bwplotka@gmail.com