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

Add Datadog profiler #314

Merged
merged 12 commits into from
Apr 5, 2022
Merged

Add Datadog profiler #314

merged 12 commits into from
Apr 5, 2022

Conversation

daxmc99
Copy link
Contributor

@daxmc99 daxmc99 commented Mar 25, 2022

  • Add Datadog as a supported profiler
    - Print an error if GOMAXPROCs fails

Adds Datadog profiler
Part of #294

daxmc99 added 2 commits March 24, 2022 17:15
With cgroups v2 becoming more common, this may not longer work for some container runtimes
@cla-bot cla-bot bot added the cla-signed label Mar 25, 2022
Copy link
Member

@keegancsmith keegancsmith left a 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)
Copy link
Member

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.

Copy link
Contributor Author

@daxmc99 daxmc99 Mar 25, 2022

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.

Copy link
Member

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.

if os.Getenv("DD_PROFILE_ALL") != "" || blockProfileRate > 0 {
profileTypes = append(profileTypes, ddprofiler.MutexProfile, ddprofiler.BlockProfile)
}
return ddprofiler.Start(
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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?

@keegancsmith
Copy link
Member

Test failure looks unrelated. cc @ggilmore

--- FAIL: TestDeltaShards (0.63s)
    --- FAIL: TestDeltaShards/tombstones_affect_document_across_branches (0.12s)
Error:         e2e_test.go:753: step "tombstone foo": finishing builder: repository metadata in shard "/tmp/TestDeltaShardstombstones_affect_document_across_branches1240476489/001/repository_v16.00000.zoekt" contains a different set of branch names than what was requested, which is unsupported in a delta shard build. old: [{Name:main Version:} {Name:release Version:}], new: [{Name:release Version:} {Name:main Version:}]

@daxmc99 daxmc99 requested a review from keegancsmith March 25, 2022 05:53
runtime.SetBlockProfileRate(conf.blockProfileRate)

profiler.Init("zoekt-sourcegraph-indexserver", zoekt.Version, conf.blockProfileRate)
Copy link
Member

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?

Copy link
Contributor

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).

@ggilmore
Copy link
Contributor

Test failure looks unrelated. cc @ggilmore

--- FAIL: TestDeltaShards (0.63s)
    --- FAIL: TestDeltaShards/tombstones_affect_document_across_branches (0.12s)
Error:         e2e_test.go:753: step "tombstone foo": finishing builder: repository metadata in shard "/tmp/TestDeltaShardstombstones_affect_document_across_branches1240476489/001/repository_v16.00000.zoekt" contains a different set of branch names than what was requested, which is unsupported in a delta shard build. old: [{Name:main Version:} {Name:release Version:}], new: [{Name:release Version:} {Name:main Version:}]

This should be fixed if you merge in master.

@daxmc99 daxmc99 force-pushed the dax/add_dd_profiler branch from a72f514 to 5fbe4e0 Compare April 5, 2022 21:36
@daxmc99 daxmc99 merged commit 2a5b562 into master Apr 5, 2022
@daxmc99 daxmc99 deleted the dax/add_dd_profiler branch April 5, 2022 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants