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

[Profiler] Add Callstack::CopyFrom method #5842

Merged
merged 2 commits into from
Aug 5, 2024

Conversation

gleocadie
Copy link
Collaborator

Summary of changes

Add CopyFrom method.

Reason for change

This is a first part in an optimization for the walltime. We will need to copy callstacks.

Implementation details

  • Add CopyFrom method

Test coverage

  • Add a unit test for it.

Other details

@gleocadie gleocadie requested a review from a team as a code owner August 2, 2024 08:43
@github-actions github-actions bot added the area:profiler Issues related to the continous-profiler label Aug 2, 2024
@datadog-ddstaging
Copy link

datadog-ddstaging bot commented Aug 2, 2024

Datadog Report

Branch report: gleocadie/improve-callstack-api
Commit report: ee8feca
Test service: dd-trace-dotnet

❌ 1 Failed (0 Known Flaky), 345872 Passed, 2041 Skipped, 15h 57m 53.01s Total Time

❌ Failed Tests (1)

  • CheckApplicationDoesNotEndUpInDeadlock - Datadog.Profiler.IntegrationTests.LinuxOnly.DlIteratePhdrDeadlock - Details

    Expand for error
     The test Samples.Computer01 is running for too long or was lost
    

@andrewlock
Copy link
Member

Execution-Time Benchmarks Report ⏱️

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 (5842) - mean (74ms)  : 65, 83
     .   : milestone, 74,
    master - mean (73ms)  : 63, 82
     .   : milestone, 73,

    section CallTarget+Inlining+NGEN
    This PR (5842) - mean (1,044ms)  : 1021, 1067
     .   : milestone, 1044,
    master - mean (1,039ms)  : 1016, 1063
     .   : milestone, 1039,

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

    section CallTarget+Inlining+NGEN
    This PR (5842) - mean (737ms)  : 715, 760
     .   : milestone, 737,
    master - mean (727ms)  : 706, 748
     .   : milestone, 727,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5842) - mean (92ms)  : 89, 96
     .   : milestone, 92,
    master - mean (92ms)  : 89, 95
     .   : milestone, 92,

    section CallTarget+Inlining+NGEN
    This PR (5842) - mean (681ms)  : 657, 705
     .   : milestone, 681,
    master - mean (679ms)  : 649, 709
     .   : milestone, 679,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5842) - mean (191ms)  : 188, 195
     .   : milestone, 191,
    master - mean (192ms)  : 188, 195
     .   : milestone, 192,

    section CallTarget+Inlining+NGEN
    This PR (5842) - mean (1,142ms)  : 1115, 1168
     .   : milestone, 1142,
    master - mean (1,147ms)  : 1118, 1175
     .   : milestone, 1147,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5842) - mean (276ms)  : 272, 280
     .   : milestone, 276,
    master - mean (276ms)  : 270, 282
     .   : milestone, 276,

    section CallTarget+Inlining+NGEN
    This PR (5842) - mean (910ms)  : 886, 934
     .   : milestone, 910,
    master - mean (904ms)  : 882, 927
     .   : milestone, 904,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5842) - mean (267ms)  : 262, 273
     .   : milestone, 267,
    master - mean (266ms)  : 262, 269
     .   : milestone, 266,

    section CallTarget+Inlining+NGEN
    This PR (5842) - mean (884ms)  : 862, 907
     .   : milestone, 884,
    master - mean (883ms)  : 859, 906
     .   : milestone, 883,

Loading

@andrewlock
Copy link
Member

Benchmarks Report for tracer 🐌

Benchmarks for #5842 compared to master:

  • 3 benchmarks are faster, with geometric mean 1.117
  • 2 benchmarks are slower, with geometric mean 1.128
  • 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 ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartStopWithChild net6.0 7.71μs 43.4ns 304ns 0.0165 0.00826 0 5.43 KB
master StartStopWithChild netcoreapp3.1 9.96μs 52.6ns 273ns 0.015 0.00501 0 5.62 KB
master StartStopWithChild net472 15.9μs 30.8ns 119ns 1.01 0.289 0.0938 6.07 KB
#5842 StartStopWithChild net6.0 7.84μs 45.4ns 366ns 0.0126 0.00419 0 5.42 KB
#5842 StartStopWithChild netcoreapp3.1 10.2μs 55ns 321ns 0.02 0.005 0 5.62 KB
#5842 StartStopWithChild net472 16.1μs 61.1ns 237ns 1.01 0.287 0.0985 6.06 KB
Benchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 461μs 480ns 1.8μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 639μs 361ns 1.3μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 848μs 459ns 1.78μs 0.425 0 0 3.3 KB
#5842 WriteAndFlushEnrichedTraces net6.0 450μs 594ns 2.3μs 0 0 0 2.7 KB
#5842 WriteAndFlushEnrichedTraces netcoreapp3.1 629μs 321ns 1.16μs 0 0 0 2.7 KB
#5842 WriteAndFlushEnrichedTraces net472 847μs 720ns 2.79μs 0.425 0 0 3.3 KB
Benchmarks.Trace.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendRequest net6.0 193μs 1μs 5.1μs 0.181 0 0 18.45 KB
master SendRequest netcoreapp3.1 217μs 1.22μs 7.78μs 0.209 0 0 20.61 KB
master SendRequest net472 0.00122ns 0.000608ns 0.00211ns 0 0 0 0 b
#5842 SendRequest net6.0 202μs 1.19μs 11.4μs 0.194 0 0 18.45 KB
#5842 SendRequest netcoreapp3.1 223μs 1.19μs 6.41μs 0.219 0 0 20.61 KB
#5842 SendRequest net472 0.00086ns 0.000541ns 0.00209ns 0 0 0 0 b
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 586μs 2.88μs 12.9μs 0.576 0 0 41.54 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 679μs 2.39μs 9.24μs 0.351 0 0 41.64 KB
master WriteAndFlushEnrichedTraces net472 846μs 3.34μs 13μs 8.17 2.45 0.408 53.27 KB
#5842 WriteAndFlushEnrichedTraces net6.0 557μs 2.81μs 12.6μs 0.543 0 0 41.66 KB
#5842 WriteAndFlushEnrichedTraces netcoreapp3.1 677μs 3.13μs 12.1μs 0.338 0 0 41.72 KB
#5842 WriteAndFlushEnrichedTraces net472 876μs 3.47μs 13.4μs 8.08 2.55 0.425 53.32 KB
Benchmarks.Trace.DbCommandBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteNonQuery net6.0 1.19μs 1.49ns 5.76ns 0.0143 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.72μs 1.15ns 4.47ns 0.0139 0 0 1.02 KB
master ExecuteNonQuery net472 1.96μs 2.41ns 9.35ns 0.156 0 0 987 B
#5842 ExecuteNonQuery net6.0 1.2μs 0.929ns 3.6ns 0.0146 0 0 1.02 KB
#5842 ExecuteNonQuery netcoreapp3.1 1.69μs 1.75ns 6.79ns 0.0135 0 0 1.02 KB
#5842 ExecuteNonQuery net472 2.04μs 1.77ns 6.87ns 0.156 0 0 987 B
Benchmarks.Trace.ElasticsearchBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master CallElasticsearch net6.0 1.24μs 0.841ns 3.26ns 0.0137 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.46μs 0.923ns 3.45ns 0.0134 0 0 976 B
master CallElasticsearch net472 2.48μs 1.75ns 6.55ns 0.158 0 0 995 B
master CallElasticsearchAsync net6.0 1.24μs 0.368ns 1.43ns 0.013 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.66μs 0.89ns 3.33ns 0.0141 0 0 1.02 KB
master CallElasticsearchAsync net472 2.57μs 1.74ns 6.5ns 0.166 0 0 1.05 KB
#5842 CallElasticsearch net6.0 1.29μs 0.753ns 2.82ns 0.0136 0 0 976 B
#5842 CallElasticsearch netcoreapp3.1 1.51μs 1.1ns 4.25ns 0.0128 0 0 976 B
#5842 CallElasticsearch net472 2.43μs 1.29ns 4.81ns 0.158 0 0 995 B
#5842 CallElasticsearchAsync net6.0 1.18μs 0.578ns 2.16ns 0.013 0 0 952 B
#5842 CallElasticsearchAsync netcoreapp3.1 1.71μs 2.68ns 10.4ns 0.0137 0 0 1.02 KB
#5842 CallElasticsearchAsync net472 2.58μs 1.6ns 6.18ns 0.166 0.00129 0 1.05 KB
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteAsync net6.0 1.29μs 0.304ns 1.14ns 0.0136 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.64μs 0.904ns 3.5ns 0.0123 0 0 952 B
master ExecuteAsync net472 1.7μs 0.816ns 3.16ns 0.145 0 0 915 B
#5842 ExecuteAsync net6.0 1.38μs 1.88ns 7.27ns 0.0131 0 0 952 B
#5842 ExecuteAsync netcoreapp3.1 1.71μs 1.15ns 4.46ns 0.0127 0 0 952 B
#5842 ExecuteAsync net472 1.75μs 1.6ns 6.21ns 0.145 0 0 915 B
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendAsync net6.0 4.14μs 2ns 7.74ns 0.0309 0 0 2.22 KB
master SendAsync netcoreapp3.1 5.02μs 2.32ns 8.98ns 0.0376 0 0 2.76 KB
master SendAsync net472 7.8μs 4.4ns 17.1ns 0.499 0 0 3.15 KB
#5842 SendAsync net6.0 4.24μs 1.64ns 6.34ns 0.0297 0 0 2.22 KB
#5842 SendAsync netcoreapp3.1 5.1μs 2.34ns 9.07ns 0.0357 0 0 2.76 KB
#5842 SendAsync net472 7.75μs 2.67ns 10.3ns 0.497 0 0 3.15 KB
Benchmarks.Trace.ILoggerBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 1.41μs 0.54ns 2.02ns 0.0235 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.31μs 1.2ns 4.48ns 0.0219 0 0 1.64 KB
master EnrichedLog net472 2.62μs 0.883ns 3.42ns 0.249 0 0 1.57 KB
#5842 EnrichedLog net6.0 1.42μs 0.733ns 2.84ns 0.0234 0 0 1.64 KB
#5842 EnrichedLog netcoreapp3.1 2.1μs 1.44ns 5.58ns 0.022 0 0 1.64 KB
#5842 EnrichedLog net472 2.54μs 0.981ns 3.54ns 0.25 0 0 1.57 KB
Benchmarks.Trace.Log4netBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 113μs 219ns 848ns 0.0557 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 119μs 286ns 1.11μs 0.059 0 0 4.28 KB
master EnrichedLog net472 149μs 335ns 1.3μs 0.67 0.223 0 4.46 KB
#5842 EnrichedLog net6.0 114μs 254ns 982ns 0.0573 0 0 4.28 KB
#5842 EnrichedLog netcoreapp3.1 121μs 249ns 966ns 0.0591 0 0 4.28 KB
#5842 EnrichedLog net472 148μs 376ns 1.46μs 0.666 0.222 0 4.46 KB
Benchmarks.Trace.NLogBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 2.93μs 1.54ns 5.76ns 0.0308 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.23μs 1.03ns 4ns 0.0288 0 0 2.2 KB
master EnrichedLog net472 4.81μs 1.35ns 5.21ns 0.319 0 0 2.02 KB
#5842 EnrichedLog net6.0 2.97μs 0.899ns 3.48ns 0.0313 0 0 2.2 KB
#5842 EnrichedLog netcoreapp3.1 4.32μs 1.89ns 7.32ns 0.0303 0 0 2.2 KB
#5842 EnrichedLog net472 4.83μs 1.43ns 5.52ns 0.319 0 0 2.02 KB
Benchmarks.Trace.RedisBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendReceive net6.0 1.31μs 2.07ns 8.02ns 0.0158 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.71μs 0.984ns 3.81ns 0.0154 0 0 1.14 KB
master SendReceive net472 2.14μs 0.819ns 3.06ns 0.184 0.00107 0 1.16 KB
#5842 SendReceive net6.0 1.34μs 0.797ns 3.09ns 0.016 0 0 1.14 KB
#5842 SendReceive netcoreapp3.1 1.73μs 1.57ns 6.09ns 0.0148 0 0 1.14 KB
#5842 SendReceive net472 2.14μs 1.34ns 5.21ns 0.183 0 0 1.16 KB
Benchmarks.Trace.SerilogBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 2.68μs 0.955ns 3.57ns 0.0228 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 4μs 14ns 52.5ns 0.0214 0 0 1.65 KB
master EnrichedLog net472 4.22μs 3.43ns 13.3ns 0.322 0 0 2.04 KB
#5842 EnrichedLog net6.0 2.8μs 1.12ns 4.32ns 0.0217 0 0 1.6 KB
#5842 EnrichedLog netcoreapp3.1 3.66μs 1.02ns 3.96ns 0.022 0 0 1.65 KB
#5842 EnrichedLog net472 4.47μs 1.9ns 7.34ns 0.322 0 0 2.04 KB
Benchmarks.Trace.SpanBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #5842

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishScope‑netcoreapp3.1 1.138 707.88 805.34
Benchmarks.Trace.SpanBenchmark.StartFinishScope‑net6.0 1.118 482.60 539.38

Faster 🎉 in #5842

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net472 1.115 707.04 634.06
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net6.0 1.114 458.22 411.30

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 458ns 0.185ns 0.715ns 0.00804 0 0 576 B
master StartFinishSpan netcoreapp3.1 550ns 0.22ns 0.853ns 0.00768 0 0 576 B
master StartFinishSpan net472 706ns 0.628ns 2.43ns 0.0917 0 0 578 B
master StartFinishScope net6.0 483ns 0.594ns 2.3ns 0.00968 0 0 696 B
master StartFinishScope netcoreapp3.1 708ns 0.177ns 0.64ns 0.00922 0 0 696 B
master StartFinishScope net472 855ns 0.561ns 2.02ns 0.105 0 0 658 B
#5842 StartFinishSpan net6.0 411ns 0.463ns 1.73ns 0.00818 0 0 576 B
#5842 StartFinishSpan netcoreapp3.1 582ns 0.37ns 1.33ns 0.00777 0 0 576 B
#5842 StartFinishSpan net472 633ns 0.699ns 2.71ns 0.0917 0 0 578 B
#5842 StartFinishScope net6.0 539ns 0.115ns 0.415ns 0.0097 0 0 696 B
#5842 StartFinishScope netcoreapp3.1 805ns 0.298ns 1.15ns 0.00951 0 0 696 B
#5842 StartFinishScope net472 864ns 0.259ns 1ns 0.105 0 0 658 B
Benchmarks.Trace.TraceAnnotationsBenchmark - Faster 🎉 Same allocations ✔️

Faster 🎉 in #5842

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin‑netcoreapp3.1 1.121 962.51 858.79

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunOnMethodBegin net6.0 659ns 0.227ns 0.878ns 0.00964 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 962ns 0.553ns 2.14ns 0.00963 0 0 696 B
master RunOnMethodBegin net472 1.16μs 0.365ns 1.32ns 0.104 0 0 658 B
#5842 RunOnMethodBegin net6.0 631ns 0.274ns 1.06ns 0.00975 0 0 696 B
#5842 RunOnMethodBegin netcoreapp3.1 859ns 0.458ns 1.77ns 0.00944 0 0 696 B
#5842 RunOnMethodBegin net472 1.06μs 0.288ns 1.12ns 0.104 0 0 658 B

Copy link
Contributor

@chrisnas chrisnas left a comment

Choose a reason for hiding this comment

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

LGTM

@gleocadie gleocadie merged commit 70e21e7 into master Aug 5, 2024
74 of 77 checks passed
@gleocadie gleocadie deleted the gleocadie/improve-callstack-api branch August 5, 2024 12:44
@github-actions github-actions bot added this to the vNext-v3 milestone Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:profiler Issues related to the continous-profiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants