DataDog / orchestrion

Automatic compile-time instrumentation of Go code
http://datadoghq.dev/orchestrion/
Apache License 2.0
130 stars 4 forks source link

feat: add profiling of Orchestrion #217

Closed nsrip-dd closed 1 month ago

nsrip-dd commented 1 month ago

What does this PR do?

Add hidden flags to enable profiling Orchestrion. Options for writing CPU and heap profiler, as well as execution traces, with a configurable path prefix. Enabling the profiler for the parent enables it for the children. There is one of each enabled profile type per process, and each file gets the PID in its name.

Note that CPU profiling adds a ~200ms delay at the end of the app to stop profiling. This might matter more for Orchestrion since there are many normally short-lived processes.

Execution tracing should be enabled with caution since traces can be quite large. Even the other profile types can produce significant amounts of data. The profiles will have redundant symbol data. The CPU and heap profiles can be combined into a single profile to eliminate the redundancy.

Example usage:

$ mkdir profiles
$ orchestrion --profile-prefix=${PWD}/profiles --cpu-profiling=true go build
# To combine the profiles:
$ go tool pprof -proto profiles/*.pprof > cpu.pprof
# To view:
$ go tool pprof -http=localhost:6060 cpu.pprof

Motivation

Looking for hot spots & bottlenecks in Orchestrion

Reviewer's Checklist

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 3.27869% with 59 lines in your changes missing coverage. Please review.

Project coverage is 60.79%. Comparing base (e5d6424) to head (c688347). Report is 1 commits behind head on main.

Files Patch % Lines
main.go 3.27% 56 Missing and 3 partials :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #217 +/- ## ========================================== - Coverage 61.51% 60.79% -0.73% ========================================== Files 91 91 Lines 4841 4902 +61 ========================================== + Hits 2978 2980 +2 - Misses 1537 1593 +56 - Partials 326 329 +3 ``` | [Flag](https://app.codecov.io/gh/DataDog/orchestrion/pull/217/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | Coverage Δ | | |---|---|---| | [ARM64](https://app.codecov.io/gh/DataDog/orchestrion/pull/217/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `43.83% <3.27%> (-0.72%)` | :arrow_down: | | [Linux](https://app.codecov.io/gh/DataDog/orchestrion/pull/217/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `65.46% <3.27%> (-0.95%)` | :arrow_down: | | [Windows](https://app.codecov.io/gh/DataDog/orchestrion/pull/217/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `42.72% <3.27%> (-0.57%)` | :arrow_down: | | [X64](https://app.codecov.io/gh/DataDog/orchestrion/pull/217/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `60.79% <3.27%> (-0.73%)` | :arrow_down: | | [generator](https://app.codecov.io/gh/DataDog/orchestrion/pull/217/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `42.64% <ø> (ø)` | | | [go1.21](https://app.codecov.io/gh/DataDog/orchestrion/pull/217/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `52.39% <3.27%> (-0.67%)` | :arrow_down: | | [go1.22](https://app.codecov.io/gh/DataDog/orchestrion/pull/217/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `50.22% <3.27%> (-0.60%)` | :arrow_down: | | [go1.23](https://app.codecov.io/gh/DataDog/orchestrion/pull/217/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `49.00% <3.27%> (-0.58%)` | :arrow_down: | | [integration](https://app.codecov.io/gh/DataDog/orchestrion/pull/217/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `45.36% <3.27%> (-0.61%)` | :arrow_down: | | [macOS](https://app.codecov.io/gh/DataDog/orchestrion/pull/217/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `43.83% <3.27%> (-0.72%)` | :arrow_down: | | [unit](https://app.codecov.io/gh/DataDog/orchestrion/pull/217/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `39.45% <0.00%> (-0.60%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.