improbable-eng / go-srvlb

DNS SRV Load Balancer for gRPC
Apache License 2.0
42 stars 11 forks source link

Fixed possible CPU intensive go routine leak from watcher. #3

Closed bwplotka closed 7 years ago

bwplotka commented 7 years ago

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.

See: https://forum.golangbridge.org/t/runtime-siftdowntimer-consuming-60-of-the-cpu/3773

Signed-off-by: Bartek Plotka bwplotka@gmail.com

mwitkow commented 7 years ago

Legit, thanks!