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 CallTarget support for ValueTask in .NET FX and < .NET Core 3.1 #6480

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

andrewlock
Copy link
Member

Summary of changes

Add support for correct CallTarget instrumentation of methods that return ValueTask in < .NET Core 3.1 or .NET Framework

Reason for change

We already support instrumenting methods that returns ValueTask in .NET Core 3.1. However, in .NET Framework or .NET Standard 2.0, this support is provided by a package, and we currently don't support instrumenting these methods. Or rather, we just ignore the OnAsyncMethodEnd in integrations in these cases.

Implementation details

We already support ValueTask in more recent frameworks, and the support is very similar to our Task support. Unfortunately, in .NET FX we can't reference the ValueTask type itself.

To work around this, we do the following:

  • Detect that the return type is ValueTask or ValueTask<T> either by loading the type directly (.NET Core) or checking the type name (.NET Framework)
  • Duck-type the ValueTask to read the IsCompletedSuccessfully value.
    • If this is true, the task is already completed synchronously, and we can simply call the target method.
    • For ValueTask<T> we duck type Result and read that directly too.
    • If it hasn't completed, we need to extract the Task from it.
  • Duck typing is used again to extract the Task() for uncompleted ValueTask
    • At this point, it's mostly a copy-paste of the existing Task integrations
  • Once the integration returns, we need to create a "new" ValueTask instead from the previous one
    • The semantics of ValueTask require that we create a "fresh" one, we can't just "reuse" the one we got originally, because we've already retrieved the result/ awaited the inner task
    • Have to use Activator/DynamicMethod for this

Warning

The existing ValueTask/ValueTask<> and Task/Task<> integrations are written quite differently, and I'm not entirely sure why 🤔 Given the ContinuationAction() methods for both these cases operate on Task, I based on the new ValueTask integrations on the Task integrations, but if anyone has reasons why it shouldn't be, I'm all ears!

Test coverage

  • Added Task and ValueTask tests to the CallTargetNativeTests integration tests. Previously we were only testing a single Task example, and that was somewhat insufficient
  • Update the CallTargetNativeTests to explicitly assert that the OnAsyncMethodEnd methods are called for Task / ValueTask method integrations. As we provide both methods in our target integration, we were silently calling the wrong one for .NET FX
    • Prior to the fix in this PR, these updated tests would fail on < .NET Core 3.0 and .NET FX
  • Run the ValueTaskAsyncContinutationGenerator unit tests on all TFMs, not just .NET Core 3.1
  • Unit tests for the ValueTaskHelper for checking if a type is a ValueTask
  • Unit tests for the ValueTaskActivator for creating a ValueTask from a Task or Task<T>
  • Verified it fixes the issues I was seeing in the RabbitMQ integration

Other details

Required for

@andrewlock andrewlock requested a review from a team as a code owner December 23, 2024 15:19
@andrewlock andrewlock added area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) area:automatic-instrumentation Automatic instrumentation managed C# code (Datadog.Trace.ClrProfiler.Managed) labels Dec 23, 2024
@datadog-ddstaging
Copy link

datadog-ddstaging bot commented Dec 23, 2024

Datadog Report

Branch report: andrew/value-task-support
Commit report: 6c8dbe5
Test service: dd-trace-dotnet

✅ 0 Failed, 460294 Passed, 2839 Skipped, 19h 33m 23.78s Total Time

@andrewlock
Copy link
Member Author

andrewlock commented Dec 23, 2024

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 (6480) - mean (68ms)  : 66, 71
     .   : milestone, 68,
    master - mean (68ms)  : 66, 71
     .   : milestone, 68,

    section CallTarget+Inlining+NGEN
    This PR (6480) - mean (977ms)  : 944, 1011
     .   : milestone, 977,
    master - mean (978ms)  : 957, 1000
     .   : milestone, 978,

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

    section CallTarget+Inlining+NGEN
    This PR (6480) - mean (674ms)  : 659, 688
     .   : milestone, 674,
    master - mean (678ms)  : 664, 693
     .   : milestone, 678,

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

    section CallTarget+Inlining+NGEN
    This PR (6480) - mean (629ms)  : 608, 650
     .   : milestone, 629,
    master - mean (632ms)  : 616, 649
     .   : milestone, 632,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6480) - mean (194ms)  : 189, 199
     .   : milestone, 194,
    master - mean (193ms)  : 189, 198
     .   : milestone, 193,

    section CallTarget+Inlining+NGEN
    This PR (6480) - mean (1,102ms)  : 1074, 1131
     .   : milestone, 1102,
    master - mean (1,095ms)  : 1068, 1122
     .   : milestone, 1095,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6480) - mean (279ms)  : 273, 284
     .   : milestone, 279,
    master - mean (277ms)  : 272, 282
     .   : milestone, 277,

    section CallTarget+Inlining+NGEN
    This PR (6480) - mean (871ms)  : 831, 912
     .   : milestone, 871,
    master - mean (870ms)  : 840, 900
     .   : milestone, 870,

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

    section CallTarget+Inlining+NGEN
    This PR (6480) - mean (845ms)  : 817, 873
     .   : milestone, 845,
    master - mean (850ms)  : 816, 883
     .   : milestone, 850,

Loading

@andrewlock andrewlock force-pushed the andrew/value-task-support branch from ffc922e to 457a93f Compare December 23, 2024 17:06
@andrewlock
Copy link
Member Author

andrewlock commented Dec 23, 2024

Benchmarks Report for tracer 🐌

Benchmarks for #6480 compared to master:

  • 2 benchmarks are slower, with geometric mean 1.150
  • 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 8μs 41.5ns 256ns 0.0159 0.00797 0 5.61 KB
master StartStopWithChild netcoreapp3.1 10.1μs 44.2ns 165ns 0.0263 0.0105 0 5.81 KB
master StartStopWithChild net472 16.5μs 47.9ns 185ns 1.06 0.331 0.091 6.2 KB
#6480 StartStopWithChild net6.0 8.07μs 44.5ns 278ns 0.0119 0.00398 0 5.61 KB
#6480 StartStopWithChild netcoreapp3.1 10μs 54.4ns 317ns 0.0144 0.00481 0 5.8 KB
#6480 StartStopWithChild net472 16.4μs 40.6ns 157ns 1.05 0.323 0.0995 6.21 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 474μs 443ns 1.72μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 658μs 441ns 1.71μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 846μs 583ns 2.26μs 0.425 0 0 3.3 KB
#6480 WriteAndFlushEnrichedTraces net6.0 497μs 711ns 2.75μs 0 0 0 2.7 KB
#6480 WriteAndFlushEnrichedTraces netcoreapp3.1 660μs 358ns 1.39μs 0 0 0 2.7 KB
#6480 WriteAndFlushEnrichedTraces net472 864μs 644ns 2.5μs 0.431 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 154μs 965ns 9.4μs 0.169 0 0 14.47 KB
master SendRequest netcoreapp3.1 177μs 1.06μs 10.6μs 0.157 0 0 17.27 KB
master SendRequest net472 0ns 0ns 0ns 0 0 0 0 b
#6480 SendRequest net6.0 156μs 1.1μs 10.8μs 0.159 0 0 14.47 KB
#6480 SendRequest netcoreapp3.1 171μs 1μs 9.3μs 0.182 0 0 17.27 KB
#6480 SendRequest net472 0.0031ns 0.00144ns 0.00557ns 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 566μs 2.69μs 12μs 0.563 0 0 41.59 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 667μs 3.8μs 26.6μs 0.331 0 0 41.67 KB
master WriteAndFlushEnrichedTraces net472 820μs 4.1μs 18.4μs 8.69 2.48 0.414 53.32 KB
#6480 WriteAndFlushEnrichedTraces net6.0 550μs 2.44μs 9.45μs 0.568 0 0 41.61 KB
#6480 WriteAndFlushEnrichedTraces netcoreapp3.1 674μs 3.65μs 21.6μs 0.327 0 0 41.73 KB
#6480 WriteAndFlushEnrichedTraces net472 829μs 4.07μs 16.3μs 8.63 2.47 0.411 53.3 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.34μs 1.12ns 4.35ns 0.014 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.76μs 2.21ns 8.56ns 0.0132 0 0 1.02 KB
master ExecuteNonQuery net472 2.09μs 2ns 7.76ns 0.156 0.00104 0 987 B
#6480 ExecuteNonQuery net6.0 1.34μs 0.74ns 2.77ns 0.0144 0 0 1.02 KB
#6480 ExecuteNonQuery netcoreapp3.1 1.68μs 1.34ns 5.17ns 0.0136 0 0 1.02 KB
#6480 ExecuteNonQuery net472 2.02μs 1.63ns 6.33ns 0.156 0.00102 0 987 B
Benchmarks.Trace.ElasticsearchBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #6480

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync‑net6.0 1.139 1,225.37 1,395.46

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master CallElasticsearch net6.0 1.23μs 0.494ns 1.91ns 0.0136 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.5μs 2.82ns 10.9ns 0.0134 0 0 976 B
master CallElasticsearch net472 2.55μs 1.48ns 5.53ns 0.157 0 0 995 B
master CallElasticsearchAsync net6.0 1.23μs 0.454ns 1.7ns 0.0135 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.69μs 1.01ns 3.64ns 0.0136 0 0 1.02 KB
master CallElasticsearchAsync net472 2.56μs 2.59ns 10ns 0.167 0 0 1.05 KB
#6480 CallElasticsearch net6.0 1.18μs 0.884ns 3.31ns 0.0137 0 0 976 B
#6480 CallElasticsearch netcoreapp3.1 1.57μs 0.556ns 2ns 0.0133 0 0 976 B
#6480 CallElasticsearch net472 2.57μs 0.742ns 2.57ns 0.157 0 0 995 B
#6480 CallElasticsearchAsync net6.0 1.4μs 0.692ns 2.49ns 0.0133 0 0 952 B
#6480 CallElasticsearchAsync netcoreapp3.1 1.65μs 1.66ns 6.44ns 0.014 0 0 1.02 KB
#6480 CallElasticsearchAsync net472 2.6μs 2.86ns 10.7ns 0.166 0 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.37μs 0.559ns 2.09ns 0.0137 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.69μs 1.13ns 4.21ns 0.0128 0 0 952 B
master ExecuteAsync net472 1.81μs 0.455ns 1.76ns 0.145 0 0 915 B
#6480 ExecuteAsync net6.0 1.34μs 0.785ns 2.94ns 0.0128 0 0 952 B
#6480 ExecuteAsync netcoreapp3.1 1.58μs 0.714ns 2.67ns 0.0126 0 0 952 B
#6480 ExecuteAsync net472 1.74μs 0.803ns 3.11ns 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.33μs 1.38ns 4.97ns 0.0327 0 0 2.31 KB
master SendAsync netcoreapp3.1 5.43μs 1.75ns 6.54ns 0.0381 0 0 2.85 KB
master SendAsync net472 7.36μs 2.66ns 9.94ns 0.492 0 0 3.12 KB
#6480 SendAsync net6.0 4.36μs 1.86ns 7.19ns 0.0328 0 0 2.31 KB
#6480 SendAsync netcoreapp3.1 5.27μs 2.25ns 8.7ns 0.0395 0 0 2.85 KB
#6480 SendAsync net472 7.39μs 1.7ns 6.59ns 0.495 0 0 3.12 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.5μs 0.943ns 3.53ns 0.0233 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.41μs 1.75ns 6.55ns 0.0227 0 0 1.64 KB
master EnrichedLog net472 2.7μs 1.41ns 5.45ns 0.249 0 0 1.57 KB
#6480 EnrichedLog net6.0 1.46μs 1.07ns 4ns 0.0231 0 0 1.64 KB
#6480 EnrichedLog netcoreapp3.1 2.27μs 1.75ns 6.76ns 0.0215 0 0 1.64 KB
#6480 EnrichedLog net472 2.72μs 1.87ns 6.99ns 0.249 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 115μs 131ns 508ns 0.058 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 124μs 200ns 776ns 0 0 0 4.28 KB
master EnrichedLog net472 150μs 242ns 937ns 0.677 0.226 0 4.46 KB
#6480 EnrichedLog net6.0 117μs 213ns 827ns 0 0 0 4.28 KB
#6480 EnrichedLog netcoreapp3.1 120μs 278ns 1.08μs 0 0 0 4.28 KB
#6480 EnrichedLog net472 152μs 141ns 544ns 0.681 0.227 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.98μs 0.781ns 3.03ns 0.0298 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.22μs 1.5ns 5.4ns 0.0295 0 0 2.2 KB
master EnrichedLog net472 4.83μs 1.05ns 4.06ns 0.319 0 0 2.02 KB
#6480 EnrichedLog net6.0 2.88μs 1.44ns 5.38ns 0.0304 0 0 2.2 KB
#6480 EnrichedLog netcoreapp3.1 4.35μs 1.05ns 4.07ns 0.0283 0 0 2.2 KB
#6480 EnrichedLog net472 4.85μs 0.933ns 3.61ns 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.42μs 0.335ns 1.25ns 0.0163 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.85μs 0.584ns 2.18ns 0.0155 0 0 1.14 KB
master SendReceive net472 2.02μs 1.76ns 6.83ns 0.183 0 0 1.16 KB
#6480 SendReceive net6.0 1.31μs 0.978ns 3.79ns 0.0158 0 0 1.14 KB
#6480 SendReceive netcoreapp3.1 1.73μs 1.15ns 4.46ns 0.0155 0 0 1.14 KB
#6480 SendReceive net472 2.09μs 1.65ns 6.19ns 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.74μs 0.813ns 3.15ns 0.0233 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 4.07μs 2.35ns 8.78ns 0.0224 0 0 1.65 KB
master EnrichedLog net472 4.32μs 3.1ns 11.6ns 0.322 0 0 2.04 KB
#6480 EnrichedLog net6.0 2.74μs 3.9ns 15.1ns 0.0218 0 0 1.6 KB
#6480 EnrichedLog netcoreapp3.1 3.96μs 1.7ns 6.6ns 0.0216 0 0 1.65 KB
#6480 EnrichedLog net472 4.46μs 3.29ns 12.8ns 0.324 0 0 2.04 KB
Benchmarks.Trace.SpanBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #6480

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishScope‑net6.0 1.161 480.44 557.77

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 394ns 0.22ns 0.852ns 0.00808 0 0 576 B
master StartFinishSpan netcoreapp3.1 625ns 0.695ns 2.6ns 0.00764 0 0 576 B
master StartFinishSpan net472 658ns 0.454ns 1.76ns 0.0917 0 0 578 B
master StartFinishScope net6.0 481ns 0.199ns 0.769ns 0.00982 0 0 696 B
master StartFinishScope netcoreapp3.1 729ns 1.06ns 4.11ns 0.00949 0 0 696 B
master StartFinishScope net472 846ns 0.376ns 1.36ns 0.104 0 0 658 B
#6480 StartFinishSpan net6.0 409ns 0.732ns 2.83ns 0.00809 0 0 576 B
#6480 StartFinishSpan netcoreapp3.1 675ns 0.376ns 1.41ns 0.00768 0 0 576 B
#6480 StartFinishSpan net472 691ns 0.369ns 1.43ns 0.0917 0 0 578 B
#6480 StartFinishScope net6.0 558ns 0.328ns 1.23ns 0.00981 0 0 696 B
#6480 StartFinishScope netcoreapp3.1 655ns 0.598ns 2.24ns 0.00916 0 0 696 B
#6480 StartFinishScope net472 861ns 0.499ns 1.93ns 0.104 0 0 658 B
Benchmarks.Trace.TraceAnnotationsBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunOnMethodBegin net6.0 640ns 1.74ns 6.75ns 0.00959 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 897ns 1.04ns 4.02ns 0.00942 0 0 696 B
master RunOnMethodBegin net472 1.05μs 0.815ns 3.16ns 0.104 0 0 658 B
#6480 RunOnMethodBegin net6.0 592ns 0.286ns 1.11ns 0.00975 0 0 696 B
#6480 RunOnMethodBegin netcoreapp3.1 894ns 0.663ns 2.57ns 0.0094 0 0 696 B
#6480 RunOnMethodBegin net472 1.15μs 0.498ns 1.93ns 0.104 0 0 658 B

@andrewlock andrewlock force-pushed the andrew/value-task-support branch from 457a93f to 6c8dbe5 Compare December 30, 2024 09:47
@andrewlock
Copy link
Member Author

Throughput/Crank Report ⚡

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 (6480) (11.113M)   : 0, 11112891
    master (11.278M)   : 0, 11278464
    benchmarks/2.9.0 (11.144M)   : 0, 11143547

    section Automatic
    This PR (6480) (7.431M)   : 0, 7431434
    master (7.310M)   : 0, 7310284
    benchmarks/2.9.0 (7.982M)   : 0, 7981525

    section Trace stats
    master (7.466M)   : 0, 7466025

    section Manual
    master (11.098M)   : 0, 11098414

    section Manual + Automatic
    This PR (6480) (6.769M)   : 0, 6769440
    master (6.596M)   : 0, 6596135

    section DD_TRACE_ENABLED=0
    master (10.177M)   : 0, 10177094

Loading
gantt
    title Throughput Linux arm64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (6480) (9.563M)   : 0, 9563388
    master (9.615M)   : 0, 9615070
    benchmarks/2.9.0 (9.621M)   : 0, 9621397

    section Automatic
    This PR (6480) (6.501M)   : 0, 6500795
    master (6.452M)   : 0, 6452148

    section Trace stats
    master (6.369M)   : 0, 6369273

    section Manual
    master (9.539M)   : 0, 9539051

    section Manual + Automatic
    This PR (6480) (5.924M)   : 0, 5924116
    master (6.003M)   : 0, 6003427

    section DD_TRACE_ENABLED=0
    master (8.846M)   : 0, 8846180

Loading
gantt
    title Throughput Windows x64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (6480) (10.316M)   : 0, 10316293
    master (9.954M)   : 0, 9954268

    section Automatic
    This PR (6480) (6.707M)   : 0, 6706701
    master (6.674M)   : 0, 6674018

    section Trace stats
    master (7.283M)   : 0, 7282769

    section Manual
    master (10.371M)   : 0, 10370838

    section Manual + Automatic
    This PR (6480) (6.238M)   : 0, 6237748
    master (6.188M)   : 0, 6187851

    section DD_TRACE_ENABLED=0
    master (9.569M)   : 0, 9568617

Loading

@kevingosse
Copy link
Collaborator

The existing ValueTask/ValueTask<> and Task/Task<> integrations are written quite differently, and I'm not entirely sure why 🤔 Given the ContinuationAction() methods for both these cases operate on Task, I based on the new ValueTask integrations on the Task integrations, but if anyone has reasons why it shouldn't be, I'm all ears!

Initially we wrote the Task integration in such a way to avoid declaring ContinuationAction as async (to save the cost of the state-machine). Eventually we ran into an issue (#1634) and I rewrote it to async. While doing so, I added some optimizations to avoid throwing an exception whenever possible. Looks like I didn't port those optimizations to the ValueTask implementation. I don't know if I just forgot or didn't think it was worth it, or if there was a technical reason 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:automatic-instrumentation Automatic instrumentation managed C# code (Datadog.Trace.ClrProfiler.Managed) area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants