Skip to content

Fix signature size check in ModifyLocalSig (#5921 -> v2)#5938

Merged
andrewlock merged 1 commit into
release/2.xfrom
kevin/unsigned-v2
Aug 23, 2024
Merged

Fix signature size check in ModifyLocalSig (#5921 -> v2)#5938
andrewlock merged 1 commit into
release/2.xfrom
kevin/unsigned-v2

Conversation

@andrewlock

Copy link
Copy Markdown
Member

Summary of changes

Fix signature size check in ModifyLocalSig.

Reason for change

Detected by static analysis.

Implementation details

Because originalSignatureSize and len are unsigned, their subtraction is unsigned and thus can't be negative.

Other details

Backport of #5921

## Summary of changes

Fix signature size check in `ModifyLocalSig`.

## Reason for change

Detected by static analysis.

## Implementation details

Because `originalSignatureSize` and `len` are unsigned, their
subtraction is unsigned and thus can't be negative.
@andrewlock andrewlock added the area:native-library Automatic instrumentation native C++ code (Datadog.Trace.ClrProfiler.Native) label Aug 23, 2024
@andrewlock
andrewlock requested a review from a team as a code owner August 23, 2024 15:30

@dromanol dromanol left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@andrewlock

Copy link
Copy Markdown
Member Author

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 (5938) - mean (77ms)  : 65, 90
     .   : milestone, 77,

    section CallTarget+Inlining+NGEN
    This PR (5938) - mean (1,034ms)  : 1015, 1053
     .   : milestone, 1034,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5938) - mean (110ms)  : 107, 114
     .   : milestone, 110,

    section CallTarget+Inlining+NGEN
    This PR (5938) - mean (719ms)  : 702, 737
     .   : milestone, 719,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5938) - mean (94ms)  : 91, 97
     .   : milestone, 94,

    section CallTarget+Inlining+NGEN
    This PR (5938) - mean (665ms)  : 645, 686
     .   : milestone, 665,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5938) - mean (190ms)  : 187, 194
     .   : milestone, 190,

    section CallTarget+Inlining+NGEN
    This PR (5938) - mean (1,119ms)  : 1096, 1143
     .   : milestone, 1119,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5938) - mean (275ms)  : 271, 280
     .   : milestone, 275,

    section CallTarget+Inlining+NGEN
    This PR (5938) - mean (877ms)  : 853, 901
     .   : milestone, 877,

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

    section CallTarget+Inlining+NGEN
    This PR (5938) - mean (865ms)  : 841, 889
     .   : milestone, 865,

Loading

@datadog-ddstaging

datadog-ddstaging Bot commented Aug 23, 2024

Copy link
Copy Markdown

Datadog Report

Branch report: kevin/unsigned-v2
Commit report: 3f34991
Test service: dd-trace-dotnet

✅ 0 Failed, 349977 Passed, 2254 Skipped, 23h 24m 13.37s Total Time

@andrewlock

Copy link
Copy Markdown
Member Author

Benchmarks Report for tracer 🐌

Benchmarks for #5938 compared to master:

  • 2 benchmarks are faster, with geometric mean 1.142
  • 1 benchmarks have more 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.98μs 45ns 305ns 0.0188 0.0075 0 5.43 KB
master StartStopWithChild netcoreapp3.1 9.93μs 56ns 376ns 0.0297 0.0149 0 5.62 KB
master StartStopWithChild net472 15.8μs 55.7ns 216ns 1.02 0.306 0.0943 6.06 KB
#5938 StartStopWithChild net6.0 7.94μs 42.7ns 241ns 0.0172 0.00859 0 5.43 KB
#5938 StartStopWithChild netcoreapp3.1 10.2μs 55.4ns 304ns 0.0249 0.00997 0 5.62 KB
#5938 StartStopWithChild net472 16.2μs 54.1ns 210ns 1.03 0.32 0.104 6.07 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 459μs 209ns 809ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 635μs 426ns 1.59μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 845μs 532ns 1.99μs 0.422 0 0 3.3 KB
#5938 WriteAndFlushEnrichedTraces net6.0 458μs 334ns 1.16μs 0 0 0 2.7 KB
#5938 WriteAndFlushEnrichedTraces netcoreapp3.1 645μs 264ns 1.02μs 0 0 0 2.7 KB
#5938 WriteAndFlushEnrichedTraces net472 831μs 573ns 2.22μs 0.414 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 192μs 1.07μs 7.01μs 0.198 0 0 18.45 KB
master SendRequest netcoreapp3.1 214μs 1.22μs 9.35μs 0.211 0 0 20.61 KB
master SendRequest net472 0.000893ns 0.000468ns 0.00175ns 0 0 0 0 b
#5938 SendRequest net6.0 193μs 1.07μs 6.31μs 0.184 0 0 18.45 KB
#5938 SendRequest netcoreapp3.1 212μs 1.16μs 6.88μs 0.207 0 0 20.61 KB
#5938 SendRequest net472 0.00191ns 0.000866ns 0.00335ns 0 0 0 0 b
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ More allocations ⚠️

More allocations ⚠️ in #5938

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑netcoreapp3.1 41.42 KB 41.67 KB 246 B 0.59%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 573μs 989ns 3.57μs 0.536 0 0 41.76 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 731μs 3.79μs 19.3μs 0.368 0 0 41.42 KB
master WriteAndFlushEnrichedTraces net472 880μs 3.72μs 14.4μs 8.8 2.64 0.44 53.34 KB
#5938 WriteAndFlushEnrichedTraces net6.0 591μs 3.09μs 14.8μs 0.568 0 0 41.72 KB
#5938 WriteAndFlushEnrichedTraces netcoreapp3.1 670μs 3.34μs 14.9μs 0.327 0 0 41.67 KB
#5938 WriteAndFlushEnrichedTraces net472 860μs 2.75μs 10.3μs 8.56 2.57 0.428 53.28 KB
Benchmarks.Trace.DbCommandBenchmark - Faster 🎉 Same allocations ✔️

Faster 🎉 in #5938

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.DbCommandBenchmark.ExecuteNonQuery‑net6.0 1.118 1,393.67 1,246.44

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteNonQuery net6.0 1.39μs 0.903ns 3.5ns 0.0139 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.74μs 1.3ns 5.03ns 0.014 0 0 1.02 KB
master ExecuteNonQuery net472 2.07μs 2.93ns 11.4ns 0.156 0 0 987 B
#5938 ExecuteNonQuery net6.0 1.25μs 1.01ns 3.92ns 0.0144 0 0 1.02 KB
#5938 ExecuteNonQuery netcoreapp3.1 1.66μs 1.17ns 4.38ns 0.0133 0 0 1.02 KB
#5938 ExecuteNonQuery net472 2.07μs 1.74ns 6.73ns 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.22μs 1.52ns 5.7ns 0.0138 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.61μs 3.11ns 12.1ns 0.0131 0 0 976 B
master CallElasticsearch net472 2.4μs 1.63ns 6.32ns 0.158 0 0 995 B
master CallElasticsearchAsync net6.0 1.2μs 0.715ns 2.68ns 0.0132 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.61μs 0.613ns 2.3ns 0.0137 0 0 1.02 KB
master CallElasticsearchAsync net472 2.57μs 1.35ns 5.24ns 0.167 0 0 1.05 KB
#5938 CallElasticsearch net6.0 1.18μs 0.833ns 3.12ns 0.0136 0 0 976 B
#5938 CallElasticsearch netcoreapp3.1 1.68μs 0.793ns 2.97ns 0.0133 0 0 976 B
#5938 CallElasticsearch net472 2.57μs 2.19ns 8.49ns 0.157 0 0 995 B
#5938 CallElasticsearchAsync net6.0 1.17μs 0.706ns 2.64ns 0.0135 0 0 952 B
#5938 CallElasticsearchAsync netcoreapp3.1 1.61μs 0.644ns 2.32ns 0.0137 0 0 1.02 KB
#5938 CallElasticsearchAsync net472 2.53μs 2.25ns 8.73ns 0.166 0.00126 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.27μs 1.09ns 4.08ns 0.0133 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.65μs 0.858ns 3.21ns 0.0125 0 0 952 B
master ExecuteAsync net472 1.66μs 0.384ns 1.44ns 0.145 0 0 915 B
#5938 ExecuteAsync net6.0 1.34μs 0.789ns 2.95ns 0.0136 0 0 952 B
#5938 ExecuteAsync netcoreapp3.1 1.64μs 1.05ns 4.08ns 0.0132 0 0 952 B
#5938 ExecuteAsync net472 1.79μs 1.28ns 4.97ns 0.145 0.000894 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.34μs 2.08ns 7.8ns 0.0304 0 0 2.22 KB
master SendAsync netcoreapp3.1 5.08μs 1.51ns 5.64ns 0.0357 0 0 2.76 KB
master SendAsync net472 7.85μs 2.83ns 11ns 0.497 0 0 3.15 KB
#5938 SendAsync net6.0 4.26μs 0.767ns 2.77ns 0.032 0 0 2.22 KB
#5938 SendAsync netcoreapp3.1 5.15μs 2.01ns 7.8ns 0.0362 0 0 2.76 KB
#5938 SendAsync net472 7.93μs 1.77ns 6.62ns 0.499 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.49μs 0.763ns 2.96ns 0.0232 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.24μs 1.61ns 6.02ns 0.0223 0 0 1.64 KB
master EnrichedLog net472 2.65μs 1.83ns 6.59ns 0.249 0 0 1.57 KB
#5938 EnrichedLog net6.0 1.49μs 0.568ns 2.05ns 0.0232 0 0 1.64 KB
#5938 EnrichedLog netcoreapp3.1 2.13μs 1.64ns 5.9ns 0.0221 0 0 1.64 KB
#5938 EnrichedLog net472 2.67μs 2.09ns 8.08ns 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 116μs 200ns 774ns 0.0583 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 120μs 265ns 1.02μs 0 0 0 4.28 KB
master EnrichedLog net472 151μs 201ns 778ns 0.674 0.225 0 4.46 KB
#5938 EnrichedLog net6.0 115μs 235ns 911ns 0.0569 0 0 4.28 KB
#5938 EnrichedLog netcoreapp3.1 120μs 189ns 731ns 0.0611 0 0 4.28 KB
#5938 EnrichedLog net472 150μs 247ns 957ns 0.668 0.223 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 3.01μs 0.751ns 2.91ns 0.0301 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.3μs 1.37ns 5.32ns 0.0301 0 0 2.2 KB
master EnrichedLog net472 4.91μs 1.48ns 5.73ns 0.319 0 0 2.02 KB
#5938 EnrichedLog net6.0 3.08μs 0.881ns 3.41ns 0.0309 0 0 2.2 KB
#5938 EnrichedLog netcoreapp3.1 4.31μs 1.6ns 5.78ns 0.0283 0 0 2.2 KB
#5938 EnrichedLog net472 4.87μs 1.42ns 5.32ns 0.32 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.33μs 0.667ns 2.58ns 0.016 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.82μs 1.35ns 5.22ns 0.0154 0 0 1.14 KB
master SendReceive net472 2.21μs 2.01ns 7.77ns 0.183 0.00111 0 1.16 KB
#5938 SendReceive net6.0 1.32μs 0.386ns 1.39ns 0.0159 0 0 1.14 KB
#5938 SendReceive netcoreapp3.1 1.84μs 0.701ns 2.72ns 0.0156 0 0 1.14 KB
#5938 SendReceive net472 2.17μs 1.13ns 4.22ns 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.88μs 0.836ns 3.24ns 0.0216 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 4μs 1.16ns 4.48ns 0.022 0 0 1.65 KB
master EnrichedLog net472 4.32μs 2.36ns 9.14ns 0.323 0 0 2.04 KB
#5938 EnrichedLog net6.0 2.87μs 0.734ns 2.75ns 0.0216 0 0 1.6 KB
#5938 EnrichedLog netcoreapp3.1 3.79μs 1.6ns 5.98ns 0.0227 0 0 1.65 KB
#5938 EnrichedLog net472 4.41μs 2.74ns 10.6ns 0.322 0 0 2.04 KB
Benchmarks.Trace.SpanBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 403ns 0.148ns 0.574ns 0.00813 0 0 576 B
master StartFinishSpan netcoreapp3.1 623ns 0.358ns 1.34ns 0.00779 0 0 576 B
master StartFinishSpan net472 666ns 0.202ns 0.783ns 0.0916 0 0 578 B
master StartFinishScope net6.0 535ns 0.185ns 0.715ns 0.00981 0 0 696 B
master StartFinishScope netcoreapp3.1 737ns 0.29ns 1.12ns 0.00951 0 0 696 B
master StartFinishScope net472 795ns 1.02ns 3.94ns 0.104 0 0 658 B
#5938 StartFinishSpan net6.0 399ns 0.126ns 0.488ns 0.00806 0 0 576 B
#5938 StartFinishSpan netcoreapp3.1 612ns 0.435ns 1.63ns 0.0077 0 0 576 B
#5938 StartFinishSpan net472 628ns 0.267ns 1.03ns 0.0918 0 0 578 B
#5938 StartFinishScope net6.0 513ns 0.155ns 0.601ns 0.00969 0 0 696 B
#5938 StartFinishScope netcoreapp3.1 673ns 0.412ns 1.54ns 0.0091 0 0 696 B
#5938 StartFinishScope net472 832ns 0.315ns 1.22ns 0.105 0 0 658 B
Benchmarks.Trace.TraceAnnotationsBenchmark - Faster 🎉 Same allocations ✔️

Faster 🎉 in #5938

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin‑net6.0 1.165 681.18 584.47

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunOnMethodBegin net6.0 681ns 0.43ns 1.67ns 0.00963 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 979ns 0.281ns 1.09ns 0.00936 0 0 696 B
master RunOnMethodBegin net472 1.09μs 0.426ns 1.65ns 0.104 0 0 658 B
#5938 RunOnMethodBegin net6.0 584ns 0.176ns 0.683ns 0.00966 0 0 696 B
#5938 RunOnMethodBegin netcoreapp3.1 956ns 0.942ns 3.52ns 0.00945 0 0 696 B
#5938 RunOnMethodBegin net472 1.15μs 1.98ns 7.65ns 0.104 0 0 658 B

@andrewlock
andrewlock merged commit 4b9ae0c into release/2.x Aug 23, 2024
@andrewlock
andrewlock deleted the kevin/unsigned-v2 branch August 23, 2024 22:14
@github-actions github-actions Bot added this to the vNext-v2 milestone Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:native-library Automatic instrumentation native C++ code (Datadog.Trace.ClrProfiler.Native)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants