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

Bug fix: Call ticker.Stop() when aggregator is stopped #269

Merged

Conversation

byronwolfman
Copy link
Contributor

TL;DR

This is a bugfix PR that prevents the aggregator's ticker from being leaked when the statsd client is closed.

Longer version

For reasons that aren't super interesting, we have an app that periodically allocates and closes statsd clients, e.g.

d, err := statsd.New("")
// Do some stuff
err = d.Close()

The app does this frequently enough that we discovered a leaked ticker. The DataDog continuous profiler helped zero in on the problem by hinting that the app was spending an increasing number of CPU cycles on runtime.CheckTimers and runtime.netpoll/runtime.epollwait. For a one-liner change, the effect is pretty outsized! You can spot the difference:

Screen Shot 2022-11-24 at 1 31 20 PM
Screen Shot 2022-11-24 at 1 57 04 PM
Screen Shot 2022-11-24 at 1 33 29 PM
Screen Shot 2022-11-24 at 1 33 41 PM

Copy link
Contributor

@scottopell scottopell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this and writing up a detailed PR, this change looks great.

@carlosroman carlosroman merged commit 9faba32 into DataDog:master Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants