Skip to content

[ASM] Segregate asm and iast contexts functionality#6118

Merged
dromanol merged 1 commit into
masterfrom
dani/asm/refactor_request_context
Oct 9, 2024
Merged

[ASM] Segregate asm and iast contexts functionality#6118
dromanol merged 1 commit into
masterfrom
dani/asm/refactor_request_context

Conversation

@dromanol

@dromanol dromanol commented Oct 4, 2024

Copy link
Copy Markdown
Contributor

Summary of changes

As suggested in this PR comment by @andrewlock , it is better to remove ASM and IAST specific functionality from the TraceContext to theis respective contexts.

Reason for change

Code cleanup

Implementation details

Test coverage

Other details

@dromanol
dromanol requested review from a team as code owners October 4, 2024 14:21
@dromanol dromanol added area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) area:asm area:asm-iast labels Oct 4, 2024
@datadog-ddstaging

datadog-ddstaging Bot commented Oct 4, 2024

Copy link
Copy Markdown

Datadog Report

Branch report: dani/asm/refactor_request_context
Commit report: ad6c251
Test service: dd-trace-dotnet

✅ 0 Failed, 364300 Passed, 2082 Skipped, 16h 36m 26.95s Total Time
❄️ 1 New Flaky

New Flaky Tests (1)

  • NoExceptions - Datadog.Trace.ClrProfiler.IntegrationTests.SmokeTests.RuntimeMetricsShutdownSmokeTest - Last Failure

    Expand for error
     Expected exit code: 0, actual exit code: 134. Message: Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
        at System.Diagnostics.Tracing.EventPipePayloadDecoder.DecodePayload(EventMetadata ByRef, System.ReadOnlySpan\`1<Byte>)
        at System.Diagnostics.Tracing.EventPipeEventDispatcher.DispatchEventsToEventListeners()
        at System.Threading.Tasks.Task.InnerInvoke()
        at System.Threading.Tasks.Task+<>c.<.cctor>b__277_0(System.Object)
        at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
        at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread)
        at System.Threading.Tasks.Task.ExecuteEntryUnsafe(System.Threading.Thread)
        at System.Threading.Tasks.ThreadPoolTaskScheduler+<>c.<.cctor>b__10_0(System.Object)
        at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
     ...
    

@andrewlock

Copy link
Copy Markdown
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 (6118) - mean (71ms)  : 68, 73
     .   : milestone, 71,
    master - mean (70ms)  : 68, 73
     .   : milestone, 70,

    section CallTarget+Inlining+NGEN
    This PR (6118) - mean (1,107ms)  : 1076, 1138
     .   : milestone, 1107,
    master - mean (1,109ms)  : 1085, 1132
     .   : milestone, 1109,

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

    section CallTarget+Inlining+NGEN
    This PR (6118) - mean (776ms)  : 762, 789
     .   : milestone, 776,
    master - mean (773ms)  : 756, 790
     .   : milestone, 773,

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

    section CallTarget+Inlining+NGEN
    This PR (6118) - mean (730ms)  : 710, 750
     .   : milestone, 730,
    master - mean (731ms)  : 710, 753
     .   : milestone, 731,

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

    section CallTarget+Inlining+NGEN
    This PR (6118) - mean (1,201ms)  : 1172, 1230
     .   : milestone, 1201,
    master - mean (1,200ms)  : 1173, 1227
     .   : milestone, 1200,

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

    section CallTarget+Inlining+NGEN
    This PR (6118) - mean (940ms)  : 925, 955
     .   : milestone, 940,
    master - mean (940ms)  : 923, 957
     .   : milestone, 940,

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

    section CallTarget+Inlining+NGEN
    This PR (6118) - mean (929ms)  : 908, 951
     .   : milestone, 929,
    master - mean (924ms)  : 904, 944
     .   : milestone, 924,

Loading

@andrewlock

Copy link
Copy Markdown
Member

Benchmarks Report for appsec 🐌

Benchmarks for #6118 compared to master:

  • 1 benchmarks are slower, with geometric mean 1.307
  • 2 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.Asm.AppSecBodyBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #6118

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody‑net472 1.307 169.32 221.31

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master AllCycleSimpleBody net6.0 72.5μs 71.4ns 267ns 0.0723 0 0 6.01 KB
master AllCycleSimpleBody netcoreapp3.1 62.2μs 93.4ns 362ns 0.0938 0 0 6.95 KB
master AllCycleSimpleBody net472 49.1μs 76ns 284ns 1.31 0 0 8.34 KB
master AllCycleMoreComplexBody net6.0 79.3μs 80.1ns 310ns 0.117 0 0 9.51 KB
master AllCycleMoreComplexBody netcoreapp3.1 71.1μs 63.2ns 236ns 0.142 0 0 10.37 KB
master AllCycleMoreComplexBody net472 55.8μs 93.7ns 363ns 1.86 0.0278 0 11.85 KB
master ObjectExtractorSimpleBody net6.0 147ns 0.146ns 0.548ns 0.00394 0 0 280 B
master ObjectExtractorSimpleBody netcoreapp3.1 199ns 0.704ns 2.73ns 0.00363 0 0 272 B
master ObjectExtractorSimpleBody net472 169ns 0.0834ns 0.323ns 0.0446 0 0 281 B
master ObjectExtractorMoreComplexBody net6.0 3.15μs 2.42ns 8.4ns 0.0537 0 0 3.78 KB
master ObjectExtractorMoreComplexBody netcoreapp3.1 3.93μs 2.36ns 8.84ns 0.0509 0 0 3.69 KB
master ObjectExtractorMoreComplexBody net472 3.85μs 7.78ns 30.1ns 0.602 0.00774 0 3.8 KB
#6118 AllCycleSimpleBody net6.0 72.9μs 83.1ns 311ns 0.0733 0 0 6 KB
#6118 AllCycleSimpleBody netcoreapp3.1 62.5μs 90.4ns 350ns 0.093 0 0 6.95 KB
#6118 AllCycleSimpleBody net472 49μs 65.4ns 253ns 1.32 0 0 8.34 KB
#6118 AllCycleMoreComplexBody net6.0 78.7μs 60.8ns 227ns 0.118 0 0 9.51 KB
#6118 AllCycleMoreComplexBody netcoreapp3.1 69.9μs 99.2ns 384ns 0.139 0 0 10.37 KB
#6118 AllCycleMoreComplexBody net472 56.1μs 49.8ns 186ns 1.88 0.0281 0 11.85 KB
#6118 ObjectExtractorSimpleBody net6.0 145ns 0.111ns 0.415ns 0.00393 0 0 280 B
#6118 ObjectExtractorSimpleBody netcoreapp3.1 196ns 0.151ns 0.585ns 0.00373 0 0 272 B
#6118 ObjectExtractorSimpleBody net472 221ns 0.137ns 0.531ns 0.0445 0 0 281 B
#6118 ObjectExtractorMoreComplexBody net6.0 3.04μs 1.82ns 7.05ns 0.0535 0 0 3.78 KB
#6118 ObjectExtractorMoreComplexBody netcoreapp3.1 3.89μs 2.97ns 11.5ns 0.0503 0 0 3.69 KB
#6118 ObjectExtractorMoreComplexBody net472 4.24μs 5.18ns 19.4ns 0.602 0.00638 0 3.8 KB
Benchmarks.Trace.Asm.AppSecEncoderBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EncodeArgs net6.0 37.2μs 18.1ns 70.3ns 0.447 0 0 32.4 KB
master EncodeArgs netcoreapp3.1 54.3μs 32.6ns 122ns 0.434 0 0 32.4 KB
master EncodeArgs net472 66.7μs 43.8ns 170ns 5.16 0.0666 0 32.5 KB
master EncodeLegacyArgs net6.0 71.9μs 62.1ns 241ns 0 0 0 2.14 KB
master EncodeLegacyArgs netcoreapp3.1 104μs 117ns 454ns 0 0 0 2.14 KB
master EncodeLegacyArgs net472 150μs 96.1ns 372ns 0.3 0 0 2.15 KB
#6118 EncodeArgs net6.0 37.9μs 26.6ns 103ns 0.451 0 0 32.4 KB
#6118 EncodeArgs netcoreapp3.1 55.2μs 26.2ns 101ns 0.438 0 0 32.4 KB
#6118 EncodeArgs net472 66.9μs 62.1ns 240ns 5.16 0.067 0 32.5 KB
#6118 EncodeLegacyArgs net6.0 70.6μs 128ns 497ns 0 0 0 2.14 KB
#6118 EncodeLegacyArgs netcoreapp3.1 108μs 57.6ns 216ns 0 0 0 2.14 KB
#6118 EncodeLegacyArgs net472 150μs 188ns 727ns 0.299 0 0 2.15 KB
Benchmarks.Trace.Asm.AppSecWafBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunWafRealisticBenchmark net6.0 186μs 213ns 825ns 0 0 0 2.44 KB
master RunWafRealisticBenchmark netcoreapp3.1 199μs 178ns 640ns 0 0 0 2.39 KB
master RunWafRealisticBenchmark net472 209μs 42.8ns 166ns 0.314 0 0 2.46 KB
master RunWafRealisticBenchmarkWithAttack net6.0 123μs 41.5ns 144ns 0 0 0 1.47 KB
master RunWafRealisticBenchmarkWithAttack netcoreapp3.1 131μs 117ns 452ns 0 0 0 1.46 KB
master RunWafRealisticBenchmarkWithAttack net472 141μs 84.8ns 328ns 0.209 0 0 1.49 KB
#6118 RunWafRealisticBenchmark net6.0 183μs 110ns 426ns 0 0 0 2.44 KB
#6118 RunWafRealisticBenchmark netcoreapp3.1 197μs 215ns 832ns 0 0 0 2.39 KB
#6118 RunWafRealisticBenchmark net472 210μs 57.9ns 224ns 0.314 0 0 2.46 KB
#6118 RunWafRealisticBenchmarkWithAttack net6.0 122μs 80.1ns 310ns 0 0 0 1.47 KB
#6118 RunWafRealisticBenchmarkWithAttack netcoreapp3.1 130μs 86.3ns 323ns 0 0 0 1.46 KB
#6118 RunWafRealisticBenchmarkWithAttack net472 138μs 41.5ns 155ns 0.207 0 0 1.49 KB
Benchmarks.Trace.Iast.StringAspectsBenchmark - Same speed ✔️ More allocations ⚠️

More allocations ⚠️ in #6118

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0 254.47 KB 265.52 KB 11.05 KB 4.34%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net472 57.9 KB 59.74 KB 1.85 KB 3.19%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StringConcatBenchmark net6.0 57.7μs 780ns 7.65μs 0 0 0 43.44 KB
master StringConcatBenchmark netcoreapp3.1 52.3μs 246ns 953ns 0 0 0 42.64 KB
master StringConcatBenchmark net472 37.3μs 81.5ns 282ns 0 0 0 57.9 KB
master StringConcatAspectBenchmark net6.0 309μs 1.7μs 10.5μs 0 0 0 254.47 KB
master StringConcatAspectBenchmark netcoreapp3.1 302μs 5.32μs 52.2μs 0 0 0 253.93 KB
master StringConcatAspectBenchmark net472 278μs 6.02μs 59.6μs 0 0 0 278.53 KB
#6118 StringConcatBenchmark net6.0 59.8μs 683ns 6.77μs 0 0 0 43.44 KB
#6118 StringConcatBenchmark netcoreapp3.1 56.7μs 577ns 5.56μs 0 0 0 42.64 KB
#6118 StringConcatBenchmark net472 37.9μs 190ns 806ns 0 0 0 59.74 KB
#6118 StringConcatAspectBenchmark net6.0 326μs 1.69μs 7.93μs 0 0 0 265.52 KB
#6118 StringConcatAspectBenchmark netcoreapp3.1 329μs 1.81μs 12.7μs 0 0 0 252.85 KB
#6118 StringConcatAspectBenchmark net472 291μs 6.92μs 67.8μs 0 0 0 278.53 KB

@dromanol dromanol changed the title [ASK] Segregate asm and iast contexts functionality [ASM] Segregate asm and iast contexts functionality Oct 4, 2024
@andrewlock

Copy link
Copy Markdown
Member

Benchmarks Report for tracer 🐌

Benchmarks for #6118 compared to master:

  • 1 benchmarks are faster, with geometric mean 1.142
  • 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.95μs 43.3ns 245ns 0.0195 0.0078 0 5.42 KB
master StartStopWithChild netcoreapp3.1 9.96μs 52.6ns 273ns 0.0193 0.00965 0 5.61 KB
master StartStopWithChild net472 16.5μs 54.3ns 210ns 1.01 0.288 0.0931 6.07 KB
#6118 StartStopWithChild net6.0 7.83μs 44ns 295ns 0.012 0.00399 0 5.43 KB
#6118 StartStopWithChild netcoreapp3.1 9.9μs 55.8ns 370ns 0.0144 0.00481 0 5.62 KB
#6118 StartStopWithChild net472 16.6μs 26.3ns 98.6ns 1.02 0.302 0.0897 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 479μs 135ns 523ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 660μs 970ns 3.63μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 840μs 662ns 2.56μs 0.419 0 0 3.3 KB
#6118 WriteAndFlushEnrichedTraces net6.0 476μs 376ns 1.46μs 0 0 0 2.7 KB
#6118 WriteAndFlushEnrichedTraces netcoreapp3.1 657μs 485ns 1.88μs 0 0 0 2.7 KB
#6118 WriteAndFlushEnrichedTraces net472 838μs 485ns 1.81μs 0.417 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 195μs 1.13μs 9.16μs 0.195 0 0 18.45 KB
master SendRequest netcoreapp3.1 218μs 1.11μs 5.43μs 0.22 0 0 20.61 KB
master SendRequest net472 0ns 0ns 0ns 0 0 0 0 b
#6118 SendRequest net6.0 195μs 1.11μs 8.31μs 0.186 0 0 18.45 KB
#6118 SendRequest netcoreapp3.1 217μs 1.26μs 11.3μs 0.212 0 0 20.61 KB
#6118 SendRequest net472 0.00146ns 0.000553ns 0.00214ns 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 587μs 2.7μs 9.73μs 0.566 0 0 41.77 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 693μs 3.44μs 15.8μs 0.34 0 0 41.86 KB
master WriteAndFlushEnrichedTraces net472 849μs 3.83μs 14.8μs 8.17 2.45 0.408 53.31 KB
#6118 WriteAndFlushEnrichedTraces net6.0 560μs 3.05μs 16.4μs 0.556 0 0 41.64 KB
#6118 WriteAndFlushEnrichedTraces netcoreapp3.1 665μs 1.66μs 6.23μs 0.329 0 0 41.68 KB
#6118 WriteAndFlushEnrichedTraces net472 834μs 3.9μs 15.6μs 8.08 2.55 0.425 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.28μs 1.28ns 4.95ns 0.0141 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.71μs 1.89ns 7.31ns 0.0139 0 0 1.02 KB
master ExecuteNonQuery net472 2.08μs 2.33ns 9.03ns 0.157 0 0 987 B
#6118 ExecuteNonQuery net6.0 1.29μs 0.884ns 3.42ns 0.0142 0 0 1.02 KB
#6118 ExecuteNonQuery netcoreapp3.1 1.72μs 1.73ns 6.49ns 0.0137 0 0 1.02 KB
#6118 ExecuteNonQuery net472 2.07μs 2.15ns 8.33ns 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.17μs 0.591ns 2.29ns 0.0137 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.59μs 0.619ns 2.32ns 0.0135 0 0 976 B
master CallElasticsearch net472 2.51μs 1.49ns 5.75ns 0.157 0 0 995 B
master CallElasticsearchAsync net6.0 1.34μs 1.03ns 3.84ns 0.0134 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.56μs 0.904ns 3.26ns 0.0133 0 0 1.02 KB
master CallElasticsearchAsync net472 2.55μs 0.74ns 2.77ns 0.166 0 0 1.05 KB
#6118 CallElasticsearch net6.0 1.07μs 0.587ns 2.28ns 0.014 0 0 976 B
#6118 CallElasticsearch netcoreapp3.1 1.52μs 0.629ns 2.35ns 0.0132 0 0 976 B
#6118 CallElasticsearch net472 2.51μs 1.14ns 4.11ns 0.157 0 0 995 B
#6118 CallElasticsearchAsync net6.0 1.39μs 1.11ns 4.15ns 0.013 0 0 952 B
#6118 CallElasticsearchAsync netcoreapp3.1 1.66μs 1.18ns 4.4ns 0.0133 0 0 1.02 KB
#6118 CallElasticsearchAsync net472 2.59μs 0.91ns 3.28ns 0.167 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.26μs 0.748ns 2.8ns 0.013 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.57μs 2.21ns 8.28ns 0.0125 0 0 952 B
master ExecuteAsync net472 1.82μs 1.32ns 5.1ns 0.145 0 0 915 B
#6118 ExecuteAsync net6.0 1.28μs 1.33ns 5.14ns 0.0133 0 0 952 B
#6118 ExecuteAsync netcoreapp3.1 1.59μs 0.956ns 3.58ns 0.0128 0 0 952 B
#6118 ExecuteAsync net472 1.72μs 0.979ns 3.66ns 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.15μs 2.01ns 7.52ns 0.0312 0 0 2.22 KB
master SendAsync netcoreapp3.1 5.12μs 2.18ns 8.14ns 0.0359 0 0 2.76 KB
master SendAsync net472 7.75μs 3.29ns 12.7ns 0.499 0 0 3.15 KB
#6118 SendAsync net6.0 4.13μs 1.24ns 4.47ns 0.0312 0 0 2.22 KB
#6118 SendAsync netcoreapp3.1 4.99μs 2.24ns 8.37ns 0.0373 0 0 2.76 KB
#6118 SendAsync net472 7.76μs 1.83ns 7.09ns 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.55μs 0.522ns 1.81ns 0.0232 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.23μs 0.909ns 3.4ns 0.022 0 0 1.64 KB
master EnrichedLog net472 2.51μs 0.62ns 2.32ns 0.249 0 0 1.57 KB
#6118 EnrichedLog net6.0 1.45μs 1.01ns 3.77ns 0.0233 0 0 1.64 KB
#6118 EnrichedLog netcoreapp3.1 2.25μs 1.63ns 6.3ns 0.0223 0 0 1.64 KB
#6118 EnrichedLog net472 2.56μs 1.39ns 5.4ns 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 114μs 138ns 536ns 0.0568 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 118μs 110ns 427ns 0.0593 0 0 4.28 KB
master EnrichedLog net472 147μs 94.5ns 354ns 0.66 0.22 0 4.46 KB
#6118 EnrichedLog net6.0 114μs 144ns 560ns 0.0569 0 0 4.28 KB
#6118 EnrichedLog netcoreapp3.1 118μs 172ns 665ns 0.0588 0 0 4.28 KB
#6118 EnrichedLog net472 147μs 90.3ns 350ns 0.662 0.221 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 1.39ns 5.22ns 0.0312 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.04μs 1.7ns 6.56ns 0.0283 0 0 2.2 KB
master EnrichedLog net472 4.9μs 2.59ns 10ns 0.32 0 0 2.02 KB
#6118 EnrichedLog net6.0 3.09μs 0.509ns 1.9ns 0.0312 0 0 2.2 KB
#6118 EnrichedLog netcoreapp3.1 4.17μs 2.98ns 11.6ns 0.029 0 0 2.2 KB
#6118 EnrichedLog net472 4.89μs 1.89ns 7.33ns 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.718ns 2.78ns 0.0164 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.83μs 0.688ns 2.48ns 0.0154 0 0 1.14 KB
master SendReceive net472 2.14μs 0.944ns 3.53ns 0.183 0.00107 0 1.16 KB
#6118 SendReceive net6.0 1.3μs 1.02ns 3.82ns 0.0162 0 0 1.14 KB
#6118 SendReceive netcoreapp3.1 1.75μs 1.92ns 7.43ns 0.0158 0 0 1.14 KB
#6118 SendReceive net472 2.11μs 1.56ns 6.04ns 0.184 0.00105 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.79μs 0.855ns 3.31ns 0.0222 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 3.83μs 1.78ns 6.91ns 0.0229 0 0 1.65 KB
master EnrichedLog net472 4.3μs 0.96ns 3.59ns 0.322 0 0 2.04 KB
#6118 EnrichedLog net6.0 2.67μs 0.96ns 3.72ns 0.0227 0 0 1.6 KB
#6118 EnrichedLog netcoreapp3.1 3.95μs 6.7ns 25.9ns 0.0218 0 0 1.65 KB
#6118 EnrichedLog net472 4.41μs 2.64ns 10.2ns 0.323 0 0 2.04 KB
Benchmarks.Trace.SpanBenchmark - Faster 🎉 Same allocations ✔️

Faster 🎉 in #6118

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net6.0 1.142 462.55 404.92

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 463ns 0.188ns 0.727ns 0.00812 0 0 576 B
master StartFinishSpan netcoreapp3.1 565ns 0.448ns 1.74ns 0.00788 0 0 576 B
master StartFinishSpan net472 608ns 0.301ns 1.17ns 0.0917 0 0 578 B
master StartFinishScope net6.0 473ns 0.271ns 1.05ns 0.00973 0 0 696 B
master StartFinishScope netcoreapp3.1 729ns 0.47ns 1.82ns 0.00931 0 0 696 B
master StartFinishScope net472 809ns 0.491ns 1.9ns 0.104 0 0 658 B
#6118 StartFinishSpan net6.0 406ns 0.664ns 2.57ns 0.00805 0 0 576 B
#6118 StartFinishSpan netcoreapp3.1 617ns 3.1ns 13.1ns 0.00762 0 0 576 B
#6118 StartFinishSpan net472 646ns 0.232ns 0.898ns 0.0916 0 0 578 B
#6118 StartFinishScope net6.0 492ns 0.194ns 0.75ns 0.00985 0 0 696 B
#6118 StartFinishScope netcoreapp3.1 721ns 0.283ns 1.06ns 0.00948 0 0 696 B
#6118 StartFinishScope net472 896ns 3.6ns 14ns 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 656ns 0.36ns 1.39ns 0.00977 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 936ns 0.689ns 2.48ns 0.00951 0 0 696 B
master RunOnMethodBegin net472 1.15μs 0.35ns 1.35ns 0.105 0 0 658 B
#6118 RunOnMethodBegin net6.0 594ns 0.304ns 1.18ns 0.00956 0 0 696 B
#6118 RunOnMethodBegin netcoreapp3.1 919ns 0.598ns 2.32ns 0.00961 0 0 696 B
#6118 RunOnMethodBegin net472 1.15μs 0.618ns 2.39ns 0.104 0 0 658 B

@andrewlock

Copy link
Copy Markdown
Member

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 (6118) (10.976M)   : 0, 10976479
    master (11.067M)   : 0, 11067199
    benchmarks/2.9.0 (11.081M)   : 0, 11080577

    section Automatic
    This PR (6118) (7.304M)   : 0, 7304430
    master (7.314M)   : 0, 7314309
    benchmarks/2.9.0 (7.732M)   : 0, 7732233

    section Trace stats
    master (7.522M)   : 0, 7522105

    section Manual
    master (11.089M)   : 0, 11089039

    section Manual + Automatic
    This PR (6118) (6.754M)   : 0, 6754234
    master (6.818M)   : 0, 6818236

    section DD_TRACE_ENABLED=0
    master (10.233M)   : 0, 10233045

Loading
gantt
    title Throughput Linux arm64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (6118) (9.542M)   : 0, 9542014
    master (9.628M)   : 0, 9628028
    benchmarks/2.9.0 (9.798M)   : 0, 9798067

    section Automatic
    This PR (6118) (6.543M)   : 0, 6542855
    master (6.472M)   : 0, 6472350

    section Trace stats
    master (6.828M)   : 0, 6827760

    section Manual
    master (9.756M)   : 0, 9756410

    section Manual + Automatic
    This PR (6118) (6.246M)   : 0, 6245809
    master (6.092M)   : 0, 6091664

    section DD_TRACE_ENABLED=0
    master (9.056M)   : 0, 9056055

Loading
gantt
    title Throughput Windows x64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (6118) (10.012M)   : 0, 10012328
    master (10.362M)   : 0, 10362363
    benchmarks/2.9.0 (10.067M)   : 0, 10067315

    section Automatic
    This PR (6118) (6.672M)   : 0, 6671505
    master (6.848M)   : 0, 6848211
    benchmarks/2.9.0 (7.552M)   : 0, 7552193

    section Trace stats
    master (7.513M)   : 0, 7513310

    section Manual
    master (10.234M)   : 0, 10233822

    section Manual + Automatic
    This PR (6118) (6.348M)   : 0, 6348464
    master (6.352M)   : 0, 6351972

    section DD_TRACE_ENABLED=0
    master (9.543M)   : 0, 9543014

Loading

@andrewlock andrewlock left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private AppSecRequestContext GetRequestContext()
/// <summary> Gets the AppSec context </summary>
internal AppSecRequestContext AppSecRequestContext

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: I wonder if it's worth making this a method called GetOrCreateAppSecRequestContext()? I'm undecided if there's any value in that tbh, just a thought 🤷

Mostly because the subtle difference with IastRequestContext being potentially null, while AppSecRequestContext is never null slightly concerns me 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I thought the same, but I preferred the symmetry, and the nullable return does the job also, IMO

@dromanol
dromanol merged commit 8b345de into master Oct 9, 2024
@dromanol
dromanol deleted the dani/asm/refactor_request_context branch October 9, 2024 09:44
@github-actions github-actions Bot added this to the vNext-v3 milestone Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:asm area:asm-iast 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.

4 participants