dd-trace-dotnet icon indicating copy to clipboard operation
dd-trace-dotnet copied to clipboard

[Profiler] Support "auto" for profiler enablement

Open chrisnas opened this issue 1 year ago • 4 comments

Summary of changes

Make profiler enabled when DD_PROFILING_ENABLED="auto"

Reason for change

With Single Step Instrumentation deployment, this value is set when the user decides to enable the profiler. THis is supposed to be temporary until DD_INJECTION_ENABLED will contain "profiler" to enable heuristics instead of fully enabling the profiler.

Implementation details

Update different tracer and profiler configuration management codes

Test coverage

Added in profiler and tracer

Other details

chrisnas avatar Jul 03 '24 06:07 chrisnas

Datadog Report

Branch report: chrisnas/prepare_ssi_auto Commit report: 9efa280 Test service: dd-trace-dotnet

:white_check_mark: 0 Failed, 345620 Passed, 2506 Skipped, 23h 59m 2.96s Total Time

datadog-ddstaging[bot] avatar Jul 03 '24 07:07 datadog-ddstaging[bot]

Execution-Time Benchmarks Report :stopwatch:

Execution-time results for samples comparing the following branches/commits:

Execution-time benchmarks measure the whole time it takes to execute a program. And are intended to measure the one-off costs. Cases where the execution time results for the PR are worse than latest master results are shown in red. The following thresholds were used for comparing the execution times:

  • Welch test with statistical test for significance of 5%
  • Only results indicating a difference greater than 5% and 5 ms are considered.

Note that these results are based on a single point-in-time result for each branch. For full results, see the dashboard.

Graphs show the p99 interval based on the mean and StdDev of the test run, as well as the mean value of the run (shown as a diamond below the graph).

gantt
    title Execution time (ms) FakeDbCommand (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5766) - mean (74ms)  : 65, 83
     .   : milestone, 74,
    master - mean (72ms)  : 65, 80
     .   : milestone, 72,

    section CallTarget+Inlining+NGEN
    This PR (5766) - mean (1,026ms)  : 988, 1063
     .   : milestone, 1026,
    master - mean (1,018ms)  : 999, 1036
     .   : milestone, 1018,

gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5766) - mean (110ms)  : 106, 114
     .   : milestone, 110,
    master - mean (109ms)  : 106, 112
     .   : milestone, 109,

    section CallTarget+Inlining+NGEN
    This PR (5766) - mean (715ms)  : 689, 740
     .   : milestone, 715,
    master - mean (705ms)  : 682, 728
     .   : milestone, 705,

gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5766) - mean (93ms)  : 91, 95
     .   : milestone, 93,
    master - mean (92ms)  : 90, 95
     .   : milestone, 92,

    section CallTarget+Inlining+NGEN
    This PR (5766) - mean (669ms)  : 645, 693
     .   : milestone, 669,
    master - mean (665ms)  : 640, 690
     .   : milestone, 665,

gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5766) - mean (192ms)  : 187, 197
     .   : milestone, 192,
    master - mean (192ms)  : 189, 196
     .   : milestone, 192,

    section CallTarget+Inlining+NGEN
    This PR (5766) - mean (1,121ms)  : 1087, 1154
     .   : milestone, 1121,
    master - mean (1,121ms)  : 1098, 1143
     .   : milestone, 1121,

gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5766) - mean (277ms)  : 272, 283
     .   : milestone, 277,
    master - mean (278ms)  : 274, 283
     .   : milestone, 278,

    section CallTarget+Inlining+NGEN
    This PR (5766) - mean (908ms)  : 875, 942
     .   : milestone, 908,
    master - mean (912ms)  : 880, 944
     .   : milestone, 912,

gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5766) - mean (266ms)  : 260, 272
     .   : milestone, 266,
    master - mean (267ms)  : 264, 271
     .   : milestone, 267,

    section CallTarget+Inlining+NGEN
    This PR (5766) - mean (893ms)  : 873, 913
     .   : milestone, 893,
    master - mean (889ms)  : 857, 921
     .   : milestone, 889,

andrewlock avatar Jul 03 '24 10:07 andrewlock

Throughput/Crank Report:zap:

Throughput results for AspNetCoreSimpleController comparing the following branches/commits:

Cases where throughput results for the PR are worse than latest master (5% drop or greater), results are shown in red.

Note that these results are based on a single point-in-time result for each branch. For full results, see one of the many, many dashboards!

gantt
    title Throughput Linux x64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (5766) (11.963M)   : 0, 11963370
    master (12.102M)   : 0, 12102247
    benchmarks/2.9.0 (11.967M)   : 0, 11966853

    section Automatic
    This PR (5766) (8.159M)   : 0, 8158556
    master (8.089M)   : 0, 8088693
    benchmarks/2.9.0 (8.405M)   : 0, 8404892

    section Trace stats
    master (8.443M)   : 0, 8442998

    section Manual
    This PR (5766) (10.414M)   : 0, 10414130
    master (10.275M)   : 0, 10274868

    section Manual + Automatic
    This PR (5766) (7.581M)   : 0, 7581346
    master (7.533M)   : 0, 7533118

    section Version Conflict
    master (6.842M)   : 0, 6842477

gantt
    title Throughput Linux arm64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (5766) (9.475M)   : 0, 9475220
    master (9.603M)   : 0, 9602520
    benchmarks/2.9.0 (9.255M)   : 0, 9255366

    section Automatic
    This PR (5766) (6.620M)   : 0, 6620352
    master (6.457M)   : 0, 6457136

    section Trace stats
    master (6.985M)   : 0, 6985383

    section Manual
    This PR (5766) (8.324M)   : 0, 8323996
    master (8.151M)   : 0, 8151308

    section Manual + Automatic
    This PR (5766) (6.096M)   : 0, 6096057
    master (6.255M)   : 0, 6255035

    section Version Conflict
    master (5.671M)   : 0, 5670523

gantt
    title Throughput Windows x64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (5766) (9.943M)   : 0, 9942745
    master (10.319M)   : 0, 10319080
    benchmarks/2.9.0 (10.302M)   : 0, 10302396

    section Automatic
    This PR (5766) (7.174M)   : 0, 7174189
    master (7.083M)   : 0, 7083219
    benchmarks/2.9.0 (7.635M)   : 0, 7634994

    section Trace stats
    master (7.566M)   : 0, 7566202

    section Manual
    This PR (5766) (8.796M)   : 0, 8795526
    master (8.698M)   : 0, 8698395

    section Manual + Automatic
    This PR (5766) (6.864M)   : 0, 6864079
    master (6.776M)   : 0, 6776250

    section Version Conflict
    master (6.140M)   : 0, 6139972

andrewlock avatar Jul 03 '24 12:07 andrewlock

Benchmarks Report for tracer :snail:

Benchmarks for #5766 compared to master:

  • 2 benchmarks are slower, with geometric mean 1.146
  • All benchmarks have the same allocations

The following thresholds were used for comparing the benchmark speeds:

  • Mann–Whitney U test with statistical test for significance of 5%
  • Only results indicating a difference greater than 10% and 0.3 ns are considered.

Allocation changes below 0.5% are ignored.

Benchmark details

Benchmarks.Trace.ActivityBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartStopWithChild net6.0 7.67μs 41.8ns 243ns 0.0147 0.00733 0 5.43 KB
master StartStopWithChild netcoreapp3.1 9.94μs 55ns 344ns 0.0147 0.00489 0 5.62 KB
master StartStopWithChild net472 16.4μs 61.3ns 237ns 1.05 0.337 0.0882 6.07 KB
#5766 StartStopWithChild net6.0 7.75μs 43.7ns 303ns 0.015 0.00752 0 5.43 KB
#5766 StartStopWithChild netcoreapp3.1 9.97μs 56.6ns 397ns 0.0151 0.00502 0 5.62 KB
#5766 StartStopWithChild net472 17.2μs 62.3ns 241ns 1 0.303 0.0842 6.07 KB
Benchmarks.Trace.AgentWriterBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 477μs 298ns 1.08μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 641μs 225ns 871ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 820μs 364ns 1.36μs 0.425 0 0 3.3 KB
#5766 WriteAndFlushEnrichedTraces net6.0 462μs 326ns 1.26μs 0 0 0 2.7 KB
#5766 WriteAndFlushEnrichedTraces netcoreapp3.1 651μs 164ns 591ns 0 0 0 2.7 KB
#5766 WriteAndFlushEnrichedTraces net472 829μs 219ns 850ns 0.411 0 0 3.3 KB
Benchmarks.Trace.AspNetCoreBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendRequest net6.0 173μs 268ns 1.04μs 0.173 0 0 18.45 KB
master SendRequest netcoreapp3.1 187μs 256ns 991ns 0.185 0 0 20.61 KB
master SendRequest net472 7.65E‑05ns 5.49E‑05ns 0.000212ns 0 0 0 0 b
#5766 SendRequest net6.0 171μs 224ns 867ns 0.172 0 0 18.45 KB
#5766 SendRequest netcoreapp3.1 190μs 347ns 1.34μs 0.191 0 0 20.61 KB
#5766 SendRequest net472 0.000156ns 0.000104ns 0.000403ns 0 0 0 0 b
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 538μs 684ns 2.65μs 0.536 0 0 41.52 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 658μs 1.42μs 5.5μs 0.329 0 0 41.68 KB
master WriteAndFlushEnrichedTraces net472 870μs 3μs 11.6μs 8.45 2.53 0.422 53.23 KB
#5766 WriteAndFlushEnrichedTraces net6.0 537μs 182ns 657ns 0.546 0 0 41.67 KB
#5766 WriteAndFlushEnrichedTraces netcoreapp3.1 659μs 1.44μs 5.58μs 0.329 0 0 41.65 KB
#5766 WriteAndFlushEnrichedTraces net472 893μs 3.52μs 13.2μs 8.08 2.55 0.425 53.26 KB
Benchmarks.Trace.DbCommandBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteNonQuery net6.0 1.22μs 0.789ns 3.06ns 0.0142 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.64μs 0.842ns 3.15ns 0.0132 0 0 1.02 KB
master ExecuteNonQuery net472 1.92μs 1.37ns 4.93ns 0.157 0 0 987 B
#5766 ExecuteNonQuery net6.0 1.23μs 0.61ns 2.36ns 0.0142 0 0 1.02 KB
#5766 ExecuteNonQuery netcoreapp3.1 1.7μs 0.768ns 2.87ns 0.0136 0 0 1.02 KB
#5766 ExecuteNonQuery net472 2.01μs 3.53ns 13.7ns 0.156 0 0 987 B
Benchmarks.Trace.ElasticsearchBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master CallElasticsearch net6.0 1.17μs 0.464ns 1.74ns 0.0141 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.58μs 1.16ns 4.33ns 0.0134 0 0 976 B
master CallElasticsearch net472 2.53μs 1.28ns 4.79ns 0.158 0.00127 0 995 B
master CallElasticsearchAsync net6.0 1.33μs 0.539ns 2.09ns 0.0133 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.6μs 0.658ns 2.55ns 0.0137 0 0 1.02 KB
master CallElasticsearchAsync net472 2.62μs 1.69ns 6.55ns 0.166 0.0013 0 1.05 KB
#5766 CallElasticsearch net6.0 1.28μs 0.766ns 2.96ns 0.0138 0 0 976 B
#5766 CallElasticsearch netcoreapp3.1 1.49μs 0.836ns 3.13ns 0.0134 0 0 976 B
#5766 CallElasticsearch net472 2.56μs 1.29ns 4.81ns 0.158 0 0 995 B
#5766 CallElasticsearchAsync net6.0 1.24μs 0.894ns 3.46ns 0.013 0 0 952 B
#5766 CallElasticsearchAsync netcoreapp3.1 1.55μs 1.14ns 4.26ns 0.0133 0 0 1.02 KB
#5766 CallElasticsearchAsync net472 2.67μs 3.47ns 13.4ns 0.166 0.00135 0 1.05 KB
Benchmarks.Trace.GraphQLBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteAsync net6.0 1.26μs 0.786ns 3.04ns 0.0133 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.67μs 1.64ns 6.34ns 0.0126 0 0 952 B
master ExecuteAsync net472 1.76μs 1.03ns 3.97ns 0.145 0 0 915 B
#5766 ExecuteAsync net6.0 1.24μs 0.916ns 3.55ns 0.013 0 0 952 B
#5766 ExecuteAsync netcoreapp3.1 1.6μs 1.12ns 4.21ns 0.0127 0 0 952 B
#5766 ExecuteAsync net472 1.77μs 0.651ns 2.43ns 0.145 0 0 915 B
Benchmarks.Trace.HttpClientBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendAsync net6.0 4.12μs 3.79ns 14.2ns 0.0311 0 0 2.22 KB
master SendAsync netcoreapp3.1 5.09μs 2.45ns 9.5ns 0.0381 0 0 2.76 KB
master SendAsync net472 7.58μs 1.83ns 7.1ns 0.499 0 0 3.15 KB
#5766 SendAsync net6.0 4.22μs 2.4ns 9.31ns 0.0316 0 0 2.22 KB
#5766 SendAsync netcoreapp3.1 5.15μs 2.89ns 11.2ns 0.0359 0 0 2.76 KB
#5766 SendAsync net472 7.73μs 2.42ns 9.35ns 0.497 0 0 3.15 KB
Benchmarks.Trace.ILoggerBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 1.42μs 0.56ns 2.17ns 0.0228 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.25μs 0.918ns 3.44ns 0.0226 0 0 1.64 KB
master EnrichedLog net472 2.56μs 1.14ns 4.4ns 0.249 0 0 1.57 KB
#5766 EnrichedLog net6.0 1.48μs 0.447ns 1.67ns 0.023 0 0 1.64 KB
#5766 EnrichedLog netcoreapp3.1 2.22μs 1.24ns 4.64ns 0.022 0 0 1.64 KB
#5766 EnrichedLog net472 2.54μs 1.72ns 6.68ns 0.249 0 0 1.57 KB
Benchmarks.Trace.Log4netBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 115μs 144ns 557ns 0.0567 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 121μs 159ns 616ns 0.0596 0 0 4.28 KB
master EnrichedLog net472 150μs 78.4ns 304ns 0.672 0.224 0 4.46 KB
#5766 EnrichedLog net6.0 116μs 339ns 1.31μs 0.0575 0 0 4.28 KB
#5766 EnrichedLog netcoreapp3.1 119μs 122ns 458ns 0.0595 0 0 4.28 KB
#5766 EnrichedLog net472 146μs 54ns 202ns 0.656 0.219 0 4.46 KB
Benchmarks.Trace.NLogBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 3.03μs 1.62ns 6.29ns 0.0318 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.09μs 1.63ns 6.12ns 0.0307 0 0 2.2 KB
master EnrichedLog net472 4.83μs 2.25ns 8.44ns 0.319 0 0 2.02 KB
#5766 EnrichedLog net6.0 3.01μs 0.657ns 2.54ns 0.0303 0 0 2.2 KB
#5766 EnrichedLog netcoreapp3.1 4.18μs 1.11ns 4.16ns 0.0294 0 0 2.2 KB
#5766 EnrichedLog net472 4.73μs 1.59ns 6.17ns 0.319 0 0 2.02 KB
Benchmarks.Trace.RedisBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendReceive net6.0 1.45μs 0.703ns 2.72ns 0.016 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.72μs 1.6ns 5.98ns 0.0151 0 0 1.14 KB
master SendReceive net472 2.09μs 0.986ns 3.82ns 0.183 0 0 1.16 KB
#5766 SendReceive net6.0 1.38μs 0.449ns 1.68ns 0.0157 0 0 1.14 KB
#5766 SendReceive netcoreapp3.1 1.78μs 0.553ns 2.14ns 0.0151 0 0 1.14 KB
#5766 SendReceive net472 2.03μs 0.851ns 3.18ns 0.183 0 0 1.16 KB
Benchmarks.Trace.SerilogBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 2.66μs 0.455ns 1.64ns 0.0226 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 3.97μs 2ns 7.48ns 0.0219 0 0 1.65 KB
master EnrichedLog net472 4.39μs 1.55ns 5.99ns 0.322 0 0 2.04 KB
#5766 EnrichedLog net6.0 2.72μs 1.3ns 5.03ns 0.0216 0 0 1.6 KB
#5766 EnrichedLog netcoreapp3.1 3.88μs 0.88ns 3.17ns 0.0217 0 0 1.65 KB
#5766 EnrichedLog net472 4.55μs 2.67ns 10.3ns 0.322 0 0 2.04 KB
Benchmarks.Trace.SpanBenchmark - Slower :warning: Same allocations :heavy_check_mark:

Slower :warning: in #5766

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishScope‑netcoreapp3.1 1.152 669.21 771.06
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net472 1.140 626.63 714.31

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 401ns 0.194ns 0.753ns 0.00809 0 0 576 B
master StartFinishSpan netcoreapp3.1 574ns 0.749ns 2.9ns 0.00797 0 0 576 B
master StartFinishSpan net472 626ns 0.658ns 2.55ns 0.0917 0 0 578 B
master StartFinishScope net6.0 468ns 0.155ns 0.602ns 0.00974 0 0 696 B
master StartFinishScope netcoreapp3.1 669ns 0.223ns 0.863ns 0.00941 0 0 696 B
master StartFinishScope net472 850ns 0.363ns 1.36ns 0.104 0 0 658 B
#5766 StartFinishSpan net6.0 406ns 0.0558ns 0.209ns 0.00816 0 0 576 B
#5766 StartFinishSpan netcoreapp3.1 594ns 0.136ns 0.489ns 0.00777 0 0 576 B
#5766 StartFinishSpan net472 716ns 0.779ns 3.02ns 0.0916 0 0 578 B
#5766 StartFinishScope net6.0 476ns 0.268ns 1.04ns 0.00981 0 0 696 B
#5766 StartFinishScope netcoreapp3.1 771ns 0.438ns 1.7ns 0.00928 0 0 696 B
#5766 StartFinishScope net472 872ns 0.88ns 3.41ns 0.104 0 0 658 B
Benchmarks.Trace.TraceAnnotationsBenchmark - Same speed :heavy_check_mark: Same allocations :heavy_check_mark:

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunOnMethodBegin net6.0 642ns 0.26ns 1.01ns 0.00965 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 846ns 1.76ns 6.59ns 0.00933 0 0 696 B
master RunOnMethodBegin net472 1.05μs 0.685ns 2.65ns 0.104 0 0 658 B
#5766 RunOnMethodBegin net6.0 667ns 0.136ns 0.527ns 0.00978 0 0 696 B
#5766 RunOnMethodBegin netcoreapp3.1 925ns 2.11ns 8.19ns 0.00953 0 0 696 B
#5766 RunOnMethodBegin net472 1.13μs 1.11ns 4.3ns 0.104 0 0 658 B

andrewlock avatar Jul 03 '24 13:07 andrewlock