-
Notifications
You must be signed in to change notification settings - Fork 109
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
Add Datadog profiler #314
Add Datadog profiler #314
Conversation
With cgroups v2 becoming more common, this may not longer work for some container runtimes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. I have a few inline comments. I only comment in one place the feedback applies, but most of my inline comments apply to other files the pattern was applied.
runtime.SetBlockProfileRate(conf.blockProfileRate) | ||
|
||
err = profiler.Init(ServiceName, zoekt.Version, conf.blockProfileRate) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you move profiler.Init to here? Previously it happened in startServer. I believe that was intentional so we didn't capture short lived debug invocations of this binary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thought here was to keep this close to the runtime.SetBlockProfile
. If all the Datadog profiler is enabled with DD_MAX_PROFILER
then it will set this value.
I suppose I don't fully understand why we are setting the BlockProfileRate here. I'm lacking the context of why this would be set when not profiling or what affect this value would have before the change.
As far as capturing short-lived invocations, I'm not sure I follow. In all debug scenarios, I think you will need to setup an external profiler for profiles to be collected and analyzed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zoekt-sourcegraph-indexserver can be run not as a daemon, but as a short lived command just for debug purposes. Those do not need datadog/cloud profiler and shouldn't have them.
I think you should move it to where we had it before. runtime.SetBlockProfile doesn't start the block profiler, that is why it was done where ti was before.
internal/profiler/profiler.go
Outdated
if os.Getenv("DD_PROFILE_ALL") != "" || blockProfileRate > 0 { | ||
profileTypes = append(profileTypes, ddprofiler.MutexProfile, ddprofiler.BlockProfile) | ||
} | ||
return ddprofiler.Start( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are doing an early return here, and then won't start google cloud profiler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want only one profiler enabled at a time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? If that is what an operator wants, then they can only enable one envvar?
Test failure looks unrelated. cc @ggilmore
|
runtime.SetBlockProfileRate(conf.blockProfileRate) | ||
|
||
profiler.Init("zoekt-sourcegraph-indexserver", zoekt.Version, conf.blockProfileRate) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you just make it so that we call runtime.SetBlockProfileRate inside of profiler.Init? That way webserver also gets to benefit from it.
cc @ggilmore do we actually use this anymore? Should we just get rid of it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you talking about the block profiler itself? We don't run it continuously, but we have the machinery to enable it by setting an environment variable (this would we be useful while we're debugging something).
This should be fixed if you merge in master. |
Co-authored-by: Keegan Carruthers-Smith <[email protected]>
a72f514
to
5fbe4e0
Compare
- Print an error if GOMAXPROCs failsAdds Datadog profiler
Part of #294