Skip to content

Conversation

@anna-git
Copy link
Contributor

@anna-git anna-git commented Nov 26, 2025

Summary of changes

We don't need to read and marshall a byte every time

Reason for change

Implementation details

Test coverage

Other details

@github-actions github-actions bot added the area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) label Nov 26, 2025
@dd-trace-dotnet-ci-bot
Copy link

dd-trace-dotnet-ci-bot bot commented Nov 26, 2025

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing This PR (7873) and master.

✅ No regressions detected - check the details below

Full Metrics Comparison

FakeDbCommand

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration74.85 ± (74.96 - 75.64) ms74.77 ± (74.81 - 75.45) ms-0.1%
.NET Framework 4.8 - Bailout
duration80.31 ± (79.99 - 80.61) ms80.47 ± (80.35 - 81.30) ms+0.2%✅⬆️
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1074.43 ± (1074.43 - 1084.30) ms1058.08 ± (1059.00 - 1067.24) ms-1.5%
.NET Core 3.1 - Baseline
process.internal_duration_ms23.04 ± (22.95 - 23.12) ms23.12 ± (23.03 - 23.20) ms+0.3%✅⬆️
process.time_to_main_ms88.54 ± (88.17 - 88.90) ms88.35 ± (87.94 - 88.76) ms-0.2%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.93 ± (10.93 - 10.94) MB10.91 ± (10.91 - 10.92) MB-0.2%
runtime.dotnet.threads.count12 ± (12 - 12)12 ± (12 - 12)+0.0%
.NET Core 3.1 - Bailout
process.internal_duration_ms23.39 ± (23.26 - 23.52) ms22.91 ± (22.84 - 22.98) ms-2.1%
process.time_to_main_ms91.29 ± (90.73 - 91.85) ms89.55 ± (89.16 - 89.93) ms-1.9%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.97 ± (10.97 - 10.98) MB10.96 ± (10.95 - 10.96) MB-0.2%
runtime.dotnet.threads.count13 ± (13 - 13)13 ± (13 - 13)+0.0%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms222.62 ± (221.20 - 224.03) ms220.84 ± (219.39 - 222.30) ms-0.8%
process.time_to_main_ms501.21 ± (500.01 - 502.42) ms497.38 ± (496.38 - 498.39) ms-0.8%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed47.89 ± (47.87 - 47.91) MB47.89 ± (47.87 - 47.91) MB-0.0%
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)-0.5%
.NET 6 - Baseline
process.internal_duration_ms21.89 ± (21.83 - 21.95) ms21.56 ± (21.50 - 21.63) ms-1.5%
process.time_to_main_ms77.12 ± (76.85 - 77.38) ms74.73 ± (74.41 - 75.05) ms-3.1%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.62 ± (10.62 - 10.63) MB10.63 ± (10.63 - 10.63) MB+0.1%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 6 - Bailout
process.internal_duration_ms21.83 ± (21.76 - 21.91) ms21.38 ± (21.32 - 21.44) ms-2.1%
process.time_to_main_ms78.86 ± (78.43 - 79.29) ms76.14 ± (75.79 - 76.49) ms-3.5%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.67 ± (10.67 - 10.67) MB10.67 ± (10.66 - 10.67) MB-0.0%
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms213.67 ± (212.58 - 214.76) ms211.83 ± (210.77 - 212.89) ms-0.9%
process.time_to_main_ms470.26 ± (469.31 - 471.21) ms470.20 ± (469.08 - 471.31) ms-0.0%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed48.07 ± (48.04 - 48.09) MB48.08 ± (48.05 - 48.10) MB+0.0%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)-0.0%
.NET 8 - Baseline
process.internal_duration_ms20.07 ± (20.00 - 20.13) ms19.86 ± (19.79 - 19.93) ms-1.0%
process.time_to_main_ms76.36 ± (76.04 - 76.69) ms74.83 ± (74.49 - 75.18) ms-2.0%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.67 ± (7.66 - 7.68) MB7.64 ± (7.63 - 7.64) MB-0.5%
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 8 - Bailout
process.internal_duration_ms19.99 ± (19.93 - 20.05) ms19.66 ± (19.61 - 19.71) ms-1.7%
process.time_to_main_ms77.53 ± (77.21 - 77.85) ms75.72 ± (75.44 - 76.01) ms-2.3%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.71 ± (7.71 - 7.72) MB7.71 ± (7.70 - 7.71) MB-0.1%
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms195.14 ± (194.16 - 196.12) ms195.26 ± (194.27 - 196.25) ms+0.1%✅⬆️
process.time_to_main_ms458.74 ± (457.81 - 459.67) ms456.72 ± (455.68 - 457.76) ms-0.4%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed36.49 ± (36.45 - 36.53) MB36.48 ± (36.44 - 36.52) MB-0.0%
runtime.dotnet.threads.count27 ± (27 - 27)27 ± (27 - 27)+0.0%✅⬆️

HttpMessageHandler

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration192.86 ± (192.88 - 193.63) ms193.90 ± (193.72 - 194.68) ms+0.5%✅⬆️
.NET Framework 4.8 - Bailout
duration196.21 ± (196.18 - 196.62) ms197.43 ± (197.10 - 197.80) ms+0.6%✅⬆️
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1109.28 ± (1112.56 - 1121.66) ms1111.80 ± (1113.01 - 1120.89) ms+0.2%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms188.04 ± (187.60 - 188.48) ms188.98 ± (188.59 - 189.36) ms+0.5%✅⬆️
process.time_to_main_ms80.64 ± (80.43 - 80.84) ms81.04 ± (80.85 - 81.23) ms+0.5%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.14 ± (16.11 - 16.17) MB16.09 ± (16.06 - 16.12) MB-0.3%
runtime.dotnet.threads.count19 ± (19 - 20)20 ± (19 - 20)+0.4%✅⬆️
.NET Core 3.1 - Bailout
process.internal_duration_ms188.03 ± (187.68 - 188.38) ms189.52 ± (189.15 - 189.90) ms+0.8%✅⬆️
process.time_to_main_ms81.97 ± (81.84 - 82.09) ms82.64 ± (82.47 - 82.81) ms+0.8%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.18 ± (16.14 - 16.21) MB16.14 ± (16.12 - 16.17) MB-0.2%
runtime.dotnet.threads.count21 ± (21 - 21)21 ± (20 - 21)-0.1%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms408.99 ± (405.98 - 412.00) ms402.13 ± (399.21 - 405.04) ms-1.7%
process.time_to_main_ms473.16 ± (471.91 - 474.40) ms474.29 ± (473.66 - 474.92) ms+0.2%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed58.94 ± (58.84 - 59.03) MB58.63 ± (58.50 - 58.76) MB-0.5%
runtime.dotnet.threads.count29 ± (29 - 29)29 ± (29 - 29)+0.1%✅⬆️
.NET 6 - Baseline
process.internal_duration_ms217.21 ± (215.39 - 219.02) ms192.14 ± (191.82 - 192.47) ms-11.5%
process.time_to_main_ms86.16 ± (84.75 - 87.58) ms70.07 ± (69.88 - 70.26) ms-18.7%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.18 ± (16.15 - 16.20) MB16.20 ± (16.07 - 16.33) MB+0.2%✅⬆️
runtime.dotnet.threads.count20 ± (20 - 20)18 ± (18 - 18)-6.8%
.NET 6 - Bailout
process.internal_duration_ms191.87 ± (191.51 - 192.24) ms191.51 ± (191.20 - 191.82) ms-0.2%
process.time_to_main_ms71.30 ± (71.14 - 71.46) ms70.90 ± (70.80 - 71.00) ms-0.6%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.17 ± (16.06 - 16.27) MB16.33 ± (16.21 - 16.44) MB+1.0%✅⬆️
runtime.dotnet.threads.count19 ± (19 - 20)20 ± (20 - 20)+2.9%✅⬆️
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms404.19 ± (402.45 - 405.93) ms409.96 ± (407.83 - 412.10) ms+1.4%✅⬆️
process.time_to_main_ms441.00 ± (440.42 - 441.58) ms440.51 ± (439.94 - 441.09) ms-0.1%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed58.93 ± (58.78 - 59.08) MB59.08 ± (58.95 - 59.22) MB+0.3%✅⬆️
runtime.dotnet.threads.count30 ± (29 - 30)30 ± (29 - 30)-0.1%
.NET 8 - Baseline
process.internal_duration_ms190.46 ± (190.11 - 190.81) ms192.02 ± (191.61 - 192.43) ms+0.8%✅⬆️
process.time_to_main_ms69.59 ± (69.42 - 69.76) ms69.92 ± (69.75 - 70.09) ms+0.5%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.78 ± (11.74 - 11.81) MB11.75 ± (11.73 - 11.77) MB-0.3%
runtime.dotnet.threads.count18 ± (18 - 18)18 ± (18 - 18)+0.2%✅⬆️
.NET 8 - Bailout
process.internal_duration_ms189.51 ± (189.17 - 189.85) ms191.19 ± (190.81 - 191.58) ms+0.9%✅⬆️
process.time_to_main_ms70.46 ± (70.35 - 70.56) ms70.76 ± (70.63 - 70.89) ms+0.4%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.82 ± (11.78 - 11.86) MB11.79 ± (11.76 - 11.82) MB-0.2%
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)+0.7%✅⬆️
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms365.46 ± (364.06 - 366.86) ms365.36 ± (363.93 - 366.79) ms-0.0%
process.time_to_main_ms428.53 ± (427.84 - 429.22) ms429.70 ± (429.00 - 430.40) ms+0.3%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed47.85 ± (47.81 - 47.88) MB47.87 ± (47.83 - 47.90) MB+0.0%✅⬆️
runtime.dotnet.threads.count29 ± (29 - 29)29 ± (29 - 29)+0.0%✅⬆️
Comparison explanation

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 highlighted 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).

Duration charts
FakeDbCommand (.NET Framework 4.8)
gantt
    title Execution time (ms) FakeDbCommand (.NET Framework 4.8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7873) - mean (75ms)  : 71, 80
    master - mean (75ms)  : 70, 80

    section Bailout
    This PR (7873) - mean (81ms)  : 73, 88
    master - mean (80ms)  : 76, 85

    section CallTarget+Inlining+NGEN
    This PR (7873) - mean (1,063ms)  : 1005, 1122
    master - mean (1,079ms)  : 1004, 1155

Loading
FakeDbCommand (.NET Core 3.1)
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7873) - mean (119ms)  : 110, 128
    master - mean (120ms)  : 112, 127

    section Bailout
    This PR (7873) - mean (120ms)  : 114, 127
    master - mean (123ms)  : 115, 131

    section CallTarget+Inlining+NGEN
    This PR (7873) - mean (756ms)  : 716, 795
    master - mean (764ms)  : 731, 796

Loading
FakeDbCommand (.NET 6)
gantt
    title Execution time (ms) FakeDbCommand (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7873) - mean (103ms)  : 96, 111
    master - mean (106ms)  : 100, 112

    section Bailout
    This PR (7873) - mean (105ms)  : 97, 112
    master - mean (108ms)  : 102, 114

    section CallTarget+Inlining+NGEN
    This PR (7873) - mean (710ms)  : 675, 745
    master - mean (721ms)  : 694, 747

Loading
FakeDbCommand (.NET 8)
gantt
    title Execution time (ms) FakeDbCommand (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7873) - mean (103ms)  : 97, 109
    master - mean (105ms)  : 99, 112

    section Bailout
    This PR (7873) - mean (104ms)  : 98, 109
    master - mean (106ms)  : 100, 112

    section CallTarget+Inlining+NGEN
    This PR (7873) - mean (690ms)  : 660, 720
    master - mean (696ms)  : 667, 725

Loading
HttpMessageHandler (.NET Framework 4.8)
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7873) - mean (194ms)  : 189, 199
    master - mean (193ms)  : 189, 197

    section Bailout
    This PR (7873) - mean (197ms)  : 194, 201
    master - mean (196ms)  : 194, 199

    section CallTarget+Inlining+NGEN
    This PR (7873) - mean (1,117ms)  : 1060, 1174
    master - mean (1,117ms)  : 1052, 1183

Loading
HttpMessageHandler (.NET Core 3.1)
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7873) - mean (278ms)  : 272, 284
    master - mean (278ms)  : 271, 284

    section Bailout
    This PR (7873) - mean (281ms)  : 275, 286
    master - mean (278ms)  : 274, 282

    section CallTarget+Inlining+NGEN
    This PR (7873) - mean (912ms)  : 866, 958
    master - mean (914ms)  : 849, 978

Loading
HttpMessageHandler (.NET 6)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7873) - mean (271ms)  : 266, 275
    master - mean (313ms)  : 265, 361

    section Bailout
    This PR (7873) - mean (270ms)  : 266, 275
    master - mean (271ms)  : 264, 278

    section CallTarget+Inlining+NGEN
    This PR (7873) - mean (884ms)  : 849, 920
    master - mean (878ms)  : 843, 913

Loading
HttpMessageHandler (.NET 8)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (7873) - mean (272ms)  : 264, 280
    master - mean (270ms)  : 265, 275

    section Bailout
    This PR (7873) - mean (272ms)  : 266, 277
    master - mean (270ms)  : 266, 274

    section CallTarget+Inlining+NGEN
    This PR (7873) - mean (827ms)  : 812, 842
    master - mean (824ms)  : 807, 842

Loading

@pr-commenter
Copy link

pr-commenter bot commented Nov 26, 2025

Benchmarks

Benchmarks Report for benchmark platform 🐌

Benchmarks for #7873 compared to master:

  • 1 benchmarks are faster, with geometric mean 1.253
  • 1 benchmarks are slower, with geometric mean 1.128
  • 7 benchmarks have fewer allocations
  • 8 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 ✔️ Fewer allocations 🎉

Fewer allocations 🎉 in #7873

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.ActivityBenchmark.StartStopWithChild‑net472 6.09 KB 6.06 KB -32 B -0.53%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartStopWithChild net6.0 10.9μs 57.2ns 297ns 0 0 0 5.53 KB
master StartStopWithChild netcoreapp3.1 13.5μs 34.9ns 126ns 0 0 0 5.68 KB
master StartStopWithChild net472 21.6μs 118ns 710ns 0.888 0.222 0 6.09 KB
#7873 StartStopWithChild net6.0 10.7μs 57.4ns 315ns 0 0 0 5.51 KB
#7873 StartStopWithChild netcoreapp3.1 13.8μs 74.1ns 378ns 0 0 0 5.7 KB
#7873 StartStopWithChild net472 21.9μs 120ns 721ns 0.992 0.331 0.11 6.06 KB
Benchmarks.Trace.AgentWriterBenchmark - Unknown 🤷 Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 N/A N/A N/A NaN NaN NaN 0 b
master WriteAndFlushEnrichedTraces netcoreapp3.1 N/A N/A N/A NaN NaN NaN 0 b
master WriteAndFlushEnrichedTraces net472 N/A N/A N/A NaN NaN NaN 0 b
#7873 WriteAndFlushEnrichedTraces net6.0 N/A N/A N/A NaN NaN NaN 0 b
#7873 WriteAndFlushEnrichedTraces netcoreapp3.1 N/A N/A N/A NaN NaN NaN 0 b
#7873 WriteAndFlushEnrichedTraces net472 N/A N/A N/A NaN NaN NaN 0 b
Benchmarks.Trace.Asm.AppSecBodyBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master AllCycleSimpleBody net6.0 1.07μs 0.68ns 2.54ns 0 0 0 1.22 KB
master AllCycleSimpleBody netcoreapp3.1 1.38μs 7.81ns 55.8ns 0 0 0 1.2 KB
master AllCycleSimpleBody net472 1.07μs 0.45ns 1.69ns 0.192 0 0 1.23 KB
master AllCycleMoreComplexBody net6.0 7.27μs 8.12ns 30.4ns 0 0 0 4.72 KB
master AllCycleMoreComplexBody netcoreapp3.1 8.76μs 46.1ns 226ns 0 0 0 4.62 KB
master AllCycleMoreComplexBody net472 7.56μs 5.77ns 22.4ns 0.717 0 0 4.74 KB
master ObjectExtractorSimpleBody net6.0 320ns 1.82ns 12.1ns 0 0 0 280 B
master ObjectExtractorSimpleBody netcoreapp3.1 393ns 2.1ns 10.7ns 0 0 0 272 B
master ObjectExtractorSimpleBody net472 299ns 0.218ns 0.815ns 0.0443 0 0 281 B
master ObjectExtractorMoreComplexBody net6.0 6.36μs 29.6ns 119ns 0 0 0 3.78 KB
master ObjectExtractorMoreComplexBody netcoreapp3.1 7.78μs 34ns 132ns 0 0 0 3.69 KB
master ObjectExtractorMoreComplexBody net472 6.67μs 1.84ns 7.11ns 0.6 0 0 3.8 KB
#7873 AllCycleSimpleBody net6.0 1.06μs 5.66ns 30.5ns 0 0 0 1.22 KB
#7873 AllCycleSimpleBody netcoreapp3.1 1.42μs 7.87ns 50.4ns 0 0 0 1.2 KB
#7873 AllCycleSimpleBody net472 1.03μs 0.156ns 0.562ns 0.19 0 0 1.23 KB
#7873 AllCycleMoreComplexBody net6.0 7.08μs 36.5ns 175ns 0 0 0 4.72 KB
#7873 AllCycleMoreComplexBody netcoreapp3.1 8.92μs 46.8ns 229ns 0 0 0 4.62 KB
#7873 AllCycleMoreComplexBody net472 7.57μs 3.62ns 14ns 0.718 0 0 4.74 KB
#7873 ObjectExtractorSimpleBody net6.0 328ns 1.5ns 5.81ns 0 0 0 280 B
#7873 ObjectExtractorSimpleBody netcoreapp3.1 396ns 2.07ns 9.26ns 0 0 0 272 B
#7873 ObjectExtractorSimpleBody net472 301ns 0.424ns 1.53ns 0.0438 0 0 281 B
#7873 ObjectExtractorMoreComplexBody net6.0 6.29μs 28ns 108ns 0 0 0 3.78 KB
#7873 ObjectExtractorMoreComplexBody netcoreapp3.1 7.86μs 33.3ns 129ns 0 0 0 3.69 KB
#7873 ObjectExtractorMoreComplexBody net472 6.66μs 2.66ns 9.96ns 0.6 0 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 79.3μs 345ns 1.29μs 0 0 0 32.4 KB
master EncodeArgs netcoreapp3.1 97.5μs 273ns 1.06μs 0 0 0 32.4 KB
master EncodeArgs net472 110μs 28.3ns 110ns 4.97 0 0 32.51 KB
master EncodeLegacyArgs net6.0 149μs 17.2ns 64.5ns 0 0 0 2.15 KB
master EncodeLegacyArgs netcoreapp3.1 198μs 449ns 1.74μs 0 0 0 2.14 KB
master EncodeLegacyArgs net472 262μs 46ns 178ns 0 0 0 2.16 KB
#7873 EncodeArgs net6.0 76.7μs 111ns 430ns 0 0 0 32.4 KB
#7873 EncodeArgs netcoreapp3.1 95.7μs 297ns 1.15μs 0 0 0 32.4 KB
#7873 EncodeArgs net472 111μs 15.5ns 58.2ns 4.99 0 0 32.51 KB
#7873 EncodeLegacyArgs net6.0 144μs 19.3ns 72.2ns 0 0 0 2.15 KB
#7873 EncodeLegacyArgs netcoreapp3.1 198μs 26.3ns 102ns 0 0 0 2.15 KB
#7873 EncodeLegacyArgs net472 262μs 31.6ns 109ns 0 0 0 2.16 KB
Benchmarks.Trace.Asm.AppSecWafBenchmark - Same speed ✔️ More allocations ⚠️

More allocations ⚠️ in #7873

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark‑net472 0 b 8.19 KB 8.19 KB
Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack‑net472 0 b 8.19 KB 8.19 KB

Fewer allocations 🎉 in #7873

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark‑net6.0 5.48 KB 5.14 KB -336 B -6.13%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunWafRealisticBenchmark net6.0 430μs 1.21μs 4.35μs 0 0 0 5.48 KB
master RunWafRealisticBenchmark netcoreapp3.1 527μs 11.5μs 107μs 0 0 0 4.58 KB
master RunWafRealisticBenchmark net472 501μs 603ns 2.26μs 0 0 0 0 b
master RunWafRealisticBenchmarkWithAttack net6.0 318μs 794ns 2.75μs 0 0 0 3.17 KB
master RunWafRealisticBenchmarkWithAttack netcoreapp3.1 377μs 3.98μs 38.6μs 0 0 0 2.32 KB
master RunWafRealisticBenchmarkWithAttack net472 371μs 192ns 691ns 0 0 0 0 b
#7873 RunWafRealisticBenchmark net6.0 429μs 954ns 3.44μs 0 0 0 5.14 KB
#7873 RunWafRealisticBenchmark netcoreapp3.1 472μs 2.68μs 22.4μs 0 0 0 4.58 KB
#7873 RunWafRealisticBenchmark net472 504μs 438ns 1.58μs 0 0 0 8.19 KB
#7873 RunWafRealisticBenchmarkWithAttack net6.0 317μs 872ns 3.26μs 0 0 0 3.17 KB
#7873 RunWafRealisticBenchmarkWithAttack netcoreapp3.1 334μs 1.19μs 4.29μs 0 0 0 2.32 KB
#7873 RunWafRealisticBenchmarkWithAttack net472 375μs 524ns 1.89μs 0 0 0 8.19 KB
Benchmarks.Trace.AspNetCoreBenchmark - Faster 🎉 Same allocations ✔️

Faster 🎉 in #7873

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.AspNetCoreBenchmark.SendRequest‑net6.0 1.253 76,894.58 61,386.43

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendRequest net6.0 77.4μs 242ns 939ns 0 0 0 14.52 KB
master SendRequest netcoreapp3.1 71.5μs 376ns 1.84μs 0 0 0 17.42 KB
master SendRequest net472 0.00167ns 0.00105ns 0.00408ns 0 0 0 0 b
#7873 SendRequest net6.0 61.4μs 48.3ns 181ns 0 0 0 14.52 KB
#7873 SendRequest netcoreapp3.1 71.2μs 248ns 1.14μs 0 0 0 17.42 KB
#7873 SendRequest net472 0.166ns 0.00363ns 0.0141ns 0 0 0 0 b
Benchmarks.Trace.CharSliceBenchmark - Same speed ✔️ More allocations ⚠️

More allocations ⚠️ in #7873

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice‑net472 0 b 8.19 KB 8.19 KB
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool‑net472 0 b 8.19 KB 8.19 KB

Fewer allocations 🎉 in #7873

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice‑net6.0 352 B 304 B -48 B -13.64%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master OriginalCharSlice net6.0 2.01ms 580ns 2.09μs 0 0 0 640.3 KB
master OriginalCharSlice netcoreapp3.1 3.92ms 1.18μs 4.58μs 0 0 0 640.1 KB
master OriginalCharSlice net472 2.67ms 1.12μs 4.05μs 0 0 0 647.17 KB
master OptimizedCharSlice net6.0 1.56ms 1.06μs 3.97μs 0 0 0 352 B
master OptimizedCharSlice netcoreapp3.1 2.76ms 661ns 2.47μs 0 0 0 104 B
master OptimizedCharSlice net472 2.04ms 1.65μs 6.38μs 0 0 0 0 b
master OptimizedCharSliceWithPool net6.0 1.16ms 1.1μs 4.11μs 0 0 0 640 B
master OptimizedCharSliceWithPool netcoreapp3.1 1.91ms 1.38μs 5.36μs 0 0 0 104 B
master OptimizedCharSliceWithPool net472 1.13ms 739ns 2.86μs 0 0 0 0 b
#7873 OriginalCharSlice net6.0 1.97ms 2.16μs 8.38μs 0 0 0 640.98 KB
#7873 OriginalCharSlice netcoreapp3.1 3.93ms 1.37μs 5.12μs 0 0 0 640.1 KB
#7873 OriginalCharSlice net472 2.64ms 835ns 3.23μs 0 0 0 647.17 KB
#7873 OptimizedCharSlice net6.0 1.49ms 2.2μs 8.51μs 0 0 0 304 B
#7873 OptimizedCharSlice netcoreapp3.1 2.77ms 809ns 3.13μs 0 0 0 104 B
#7873 OptimizedCharSlice net472 2.03ms 1.1μs 4.25μs 0 0 0 8.19 KB
#7873 OptimizedCharSliceWithPool net6.0 1.06ms 963ns 3.73μs 0 0 0 640 B
#7873 OptimizedCharSliceWithPool netcoreapp3.1 1.9ms 2.56μs 9.92μs 0 0 0 104 B
#7873 OptimizedCharSliceWithPool net472 1.15ms 612ns 2.37μs 0 0 0 8.19 KB
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Slower ⚠️ More allocations ⚠️

Slower ⚠️ in #7873

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑net472 1.128 862,910.27 973,746.25

More allocations ⚠️ in #7873

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑netcoreapp3.1 41.94 KB 43.05 KB 1.12 KB 2.67%
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑net472 55.63 KB 56.29 KB 658 B 1.18%

Fewer allocations 🎉 in #7873

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑net6.0 41.83 KB 41.55 KB -274 B -0.66%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 771μs 3.65μs 14.1μs 0 0 0 41.83 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 685μs 1.01μs 3.77μs 0 0 0 41.94 KB
master WriteAndFlushEnrichedTraces net472 867μs 4.4μs 21.6μs 4.46 0 0 55.63 KB
#7873 WriteAndFlushEnrichedTraces net6.0 691μs 3.63μs 18.9μs 0 0 0 41.55 KB
#7873 WriteAndFlushEnrichedTraces netcoreapp3.1 758μs 2.47μs 8.92μs 0 0 0 43.05 KB
#7873 WriteAndFlushEnrichedTraces net472 981μs 4.64μs 19.7μs 8.33 0 0 56.29 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.86μs 6.69ns 25ns 0 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 2.58μs 13ns 59.7ns 0 0 0 1.02 KB
master ExecuteNonQuery net472 2.79μs 6.36ns 24.6ns 0.154 0 0 987 B
#7873 ExecuteNonQuery net6.0 1.88μs 2.61ns 10.1ns 0 0 0 1.02 KB
#7873 ExecuteNonQuery netcoreapp3.1 2.59μs 9.85ns 36.9ns 0 0 0 1.02 KB
#7873 ExecuteNonQuery net472 2.69μs 1.98ns 7.66ns 0.15 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.77μs 2.66ns 10.3ns 0 0 0 1.03 KB
master CallElasticsearch netcoreapp3.1 2.32μs 7.37ns 28.5ns 0 0 0 1.03 KB
master CallElasticsearch net472 3.49μs 7.93ns 30.7ns 0.159 0 0 1.04 KB
master CallElasticsearchAsync net6.0 1.8μs 9.28ns 41.5ns 0 0 0 1.01 KB
master CallElasticsearchAsync netcoreapp3.1 2.38μs 11.4ns 48.5ns 0 0 0 1.08 KB
master CallElasticsearchAsync net472 3.73μs 5.03ns 19.5ns 0.166 0 0 1.1 KB
#7873 CallElasticsearch net6.0 1.82μs 9.16ns 41ns 0 0 0 1.03 KB
#7873 CallElasticsearch netcoreapp3.1 2.4μs 7.53ns 29.2ns 0 0 0 1.03 KB
#7873 CallElasticsearch net472 3.46μs 1.55ns 5.99ns 0.156 0 0 1.04 KB
#7873 CallElasticsearchAsync net6.0 1.83μs 8.55ns 35.2ns 0 0 0 1.01 KB
#7873 CallElasticsearchAsync netcoreapp3.1 2.44μs 10.3ns 39.9ns 0 0 0 1.08 KB
#7873 CallElasticsearchAsync net472 3.63μs 2.08ns 8.07ns 0.166 0 0 1.1 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.94μs 4.71ns 18.3ns 0 0 0 952 B
master ExecuteAsync netcoreapp3.1 2.45μs 11.9ns 49.1ns 0 0 0 952 B
master ExecuteAsync net472 2.61μs 5.42ns 21ns 0.142 0 0 915 B
#7873 ExecuteAsync net6.0 1.99μs 2.6ns 10.1ns 0 0 0 952 B
#7873 ExecuteAsync netcoreapp3.1 2.42μs 10ns 38.7ns 0 0 0 952 B
#7873 ExecuteAsync net472 2.55μs 4.33ns 16.8ns 0.139 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 6.99μs 21.3ns 82.5ns 0 0 0 2.36 KB
master SendAsync netcoreapp3.1 8.59μs 32.3ns 125ns 0 0 0 2.9 KB
master SendAsync net472 12.2μs 9.13ns 34.2ns 0.486 0 0 3.18 KB
#7873 SendAsync net6.0 7.19μs 4.47ns 17.3ns 0 0 0 2.36 KB
#7873 SendAsync netcoreapp3.1 8.52μs 20.1ns 77.9ns 0 0 0 2.9 KB
#7873 SendAsync net472 12.5μs 7.48ns 28ns 0.503 0 0 3.18 KB
Benchmarks.Trace.Iast.StringAspectsBenchmark - Same speed ✔️ More allocations ⚠️

More allocations ⚠️ in #7873

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net472 57.34 KB 65.54 KB 8.19 KB 14.29%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0 275.34 KB 276.98 KB 1.64 KB 0.60%

Fewer allocations 🎉 in #7873

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑netcoreapp3.1 258.27 KB 250.18 KB -8.1 KB -3.13%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net472 289.19 KB 278.53 KB -10.66 KB -3.69%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net6.0 45.32 KB 43.15 KB -2.17 KB -4.78%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StringConcatBenchmark net6.0 50.8μs 414ns 3.97μs 0 0 0 45.32 KB
master StringConcatBenchmark netcoreapp3.1 50μs 291ns 2.23μs 0 0 0 43.19 KB
master StringConcatBenchmark net472 57.2μs 157ns 586ns 0 0 0 57.34 KB
master StringConcatAspectBenchmark net6.0 504μs 1.69μs 8.08μs 0 0 0 275.34 KB
master StringConcatAspectBenchmark netcoreapp3.1 491μs 1.28μs 6.38μs 0 0 0 258.27 KB
master StringConcatAspectBenchmark net472 411μs 2.2μs 11.6μs 0 0 0 289.19 KB
#7873 StringConcatBenchmark net6.0 48.8μs 259ns 1.7μs 0 0 0 43.15 KB
#7873 StringConcatBenchmark netcoreapp3.1 48.4μs 233ns 1.04μs 0 0 0 43.4 KB
#7873 StringConcatBenchmark net472 56.9μs 296ns 1.39μs 0 0 0 65.54 KB
#7873 StringConcatAspectBenchmark net6.0 493μs 2.19μs 7.91μs 0 0 0 276.98 KB
#7873 StringConcatAspectBenchmark netcoreapp3.1 499μs 2.08μs 7.2μs 0 0 0 250.18 KB
#7873 StringConcatAspectBenchmark net472 412μs 2.22μs 11.9μs 0 0 0 278.53 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 2.77μs 3.78ns 14.6ns 0 0 0 1.7 KB
master EnrichedLog netcoreapp3.1 3.57μs 18.9ns 98.4ns 0 0 0 1.7 KB
master EnrichedLog net472 4μs 5.03ns 19.5ns 0.241 0 0 1.64 KB
#7873 EnrichedLog net6.0 2.75μs 13ns 55.2ns 0 0 0 1.7 KB
#7873 EnrichedLog netcoreapp3.1 3.61μs 17.6ns 74.7ns 0 0 0 1.7 KB
#7873 EnrichedLog net472 3.91μs 2.2ns 8.21ns 0.255 0 0 1.64 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 128μs 623ns 2.65μs 0 0 0 4.31 KB
master EnrichedLog netcoreapp3.1 129μs 322ns 1.16μs 0 0 0 4.31 KB
master EnrichedLog net472 168μs 137ns 530ns 0 0 0 4.52 KB
#7873 EnrichedLog net6.0 124μs 81.3ns 315ns 0 0 0 4.31 KB
#7873 EnrichedLog netcoreapp3.1 127μs 53.4ns 193ns 0 0 0 4.31 KB
#7873 EnrichedLog net472 168μs 112ns 434ns 0 0 0 4.52 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 5.07μs 8.02ns 31.1ns 0 0 0 2.26 KB
master EnrichedLog netcoreapp3.1 6.8μs 27.1ns 105ns 0 0 0 2.26 KB
master EnrichedLog net472 7.78μs 7.7ns 29.8ns 0.307 0 0 2.08 KB
#7873 EnrichedLog net6.0 4.86μs 21.3ns 82.6ns 0 0 0 2.26 KB
#7873 EnrichedLog netcoreapp3.1 6.88μs 17.2ns 66.6ns 0 0 0 2.26 KB
#7873 EnrichedLog net472 7.96μs 4.48ns 16.8ns 0.318 0 0 2.08 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.95μs 9.1ns 34.1ns 0 0 0 1.2 KB
master SendReceive netcoreapp3.1 2.73μs 8.53ns 33ns 0 0 0 1.2 KB
master SendReceive net472 3.09μs 5.53ns 21.4ns 0.185 0 0 1.2 KB
#7873 SendReceive net6.0 1.99μs 1.12ns 4.05ns 0 0 0 1.2 KB
#7873 SendReceive netcoreapp3.1 2.6μs 9.91ns 38.4ns 0 0 0 1.2 KB
#7873 SendReceive net472 3.08μs 1.55ns 5.59ns 0.185 0 0 1.2 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 4.4μs 5.62ns 21.8ns 0 0 0 1.58 KB
master EnrichedLog netcoreapp3.1 5.86μs 10.4ns 40.2ns 0 0 0 1.63 KB
master EnrichedLog net472 6.61μs 8.71ns 33.7ns 0.295 0 0 2.03 KB
#7873 EnrichedLog net6.0 4.45μs 14.9ns 57.8ns 0 0 0 1.58 KB
#7873 EnrichedLog netcoreapp3.1 5.75μs 18.3ns 70.8ns 0 0 0 1.63 KB
#7873 EnrichedLog net472 6.7μs 8.22ns 31.8ns 0.302 0 0 2.03 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 806ns 0.304ns 1.18ns 0 0 0 576 B
master StartFinishSpan netcoreapp3.1 981ns 5.14ns 24.7ns 0 0 0 576 B
master StartFinishSpan net472 934ns 0.239ns 0.924ns 0.0899 0 0 578 B
master StartFinishScope net6.0 955ns 3.17ns 12.3ns 0 0 0 696 B
master StartFinishScope netcoreapp3.1 1.14μs 6.08ns 31ns 0 0 0 696 B
master StartFinishScope net472 1.1μs 0.221ns 0.828ns 0.1 0 0 658 B
master StartFinishTwoScopes net6.0 1.82μs 0.764ns 2.96ns 0 0 0 1.19 KB
master StartFinishTwoScopes netcoreapp3.1 2.26μs 11.3ns 49.2ns 0 0 0 1.19 KB
master StartFinishTwoScopes net472 2.12μs 2.43ns 9.42ns 0.17 0 0 1.08 KB
#7873 StartFinishSpan net6.0 819ns 4.39ns 23.7ns 0 0 0 576 B
#7873 StartFinishSpan netcoreapp3.1 992ns 5.06ns 23.7ns 0 0 0 576 B
#7873 StartFinishSpan net472 913ns 0.0534ns 0.185ns 0.0902 0 0 578 B
#7873 StartFinishScope net6.0 952ns 3.6ns 14ns 0 0 0 696 B
#7873 StartFinishScope netcoreapp3.1 1.16μs 5.91ns 27.1ns 0 0 0 696 B
#7873 StartFinishScope net472 1.1μs 0.688ns 2.57ns 0.1 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 1.13μs 5.2ns 20.8ns 0 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 1.41μs 6.92ns 29.4ns 0 0 0 696 B
master RunOnMethodBegin net472 1.46μs 0.161ns 0.601ns 0.102 0 0 658 B
#7873 RunOnMethodBegin net6.0 1.09μs 2.83ns 10.9ns 0 0 0 696 B
#7873 RunOnMethodBegin netcoreapp3.1 1.42μs 7.43ns 38.6ns 0 0 0 696 B
#7873 RunOnMethodBegin net472 1.46μs 1.61ns 6.24ns 0.102 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.

Just a question about nullability

private readonly object _lockObj;
private bool _isInitialized;
private IntPtr _engineStatusPtr;
private bool? _isProfilerReadyCache;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a specific reason to make it nullable?

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, given we assume that it's always eventually going to be ready if it's not disabled, then a simple bool seems fine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes removed in 0b0b726

@datadog-official

This comment has been minimized.

@anna-git anna-git marked this pull request as ready for review November 27, 2025 15:12
@anna-git anna-git requested review from a team as code owners November 27, 2025 15:12
@anna-git anna-git changed the title attempt: Cache is ready state for profiler Nit: cache is ready state for profiler in ProfilerStatus Nov 27, 2025
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +46 to +55
// once _isProfilerReadyCache is true, it's never false anymore
if (_isProfilerReadyCache)
{
return true;
}

EnsureNativeIsIntialized();
return _engineStatusPtr != IntPtr.Zero && Marshal.ReadByte(_engineStatusPtr) != 0;
var isReady = _engineStatusPtr != IntPtr.Zero && Marshal.ReadByte(_engineStatusPtr) != 0;
_isProfilerReadyCache = isReady;
return isReady;

Choose a reason for hiding this comment

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

P1 Badge Caching hides profiler shutdown signal

After this change IsProfilerReady returns true forever once the profiler reports ready (lines 46-55) and never re-reads the native status byte. The native engine explicitly flips that flag back to false during shutdown (ProfilerEngineStatus::WriteIsProfilerEngineActive(false) in profiler/src/ProfilerEngine/Datadog.Profiler.Native/CorProfilerCallback.cpp around the DisposeInternal path) to tell managed components to stop writing trace-context data while the engine is unloading. With the new cache, managed code will keep reporting the profiler as ready after unload (e.g., during process shutdown), so ContextTracker.IsEnabled stays true and continues P/Invokes into native buffers while they are being torn down, defeating the intended synchronization and risking writes after the profiler stops.

Useful? React with 👍 / 👎.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is it valid @chrisnas ? it seems that indeed, ContextTracer.IsEnabled is tested before some native calls happen

Copy link
Contributor

Choose a reason for hiding this comment

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

@anna-git : the comment is valid but we switch back to false AFTER the runtime shutdown. Maybe the code could be changed to only call EnsureIsInitialized() if _isProfilerReadyCache is false and keep on calling Marshal.ReadByte(). But the gain will be less...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so, after discussion, let's leave it as is to keep the cache benefit, as we should be "protected" from interop calls as the profiler checks if it hasnt been shutdown

@anna-git anna-git merged commit 183b33d into master Nov 28, 2025
194 of 195 checks passed
@anna-git anna-git deleted the anna/try-cache-profiler-state branch November 28, 2025 15:02
@github-actions github-actions bot added this to the vNext-v3 milestone Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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