Skip to content

Conversation

@bouwkast
Copy link
Collaborator

Summary of changes

Fixes a NullReferenceException in IpcTcpProcessMessageIntegration.

Reason for change

Previously the code was just doing this: tracer.InternalActiveScope is var scope

And then we were calling scope.Span.Context but the Span property can be null.

Implementation details

Swapped to the property pattern { } which should address it.

Test coverage

I didn't update any tests

Other details

@dd-trace-dotnet-ci-bot
Copy link

dd-trace-dotnet-ci-bot bot commented Dec 30, 2025

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing This PR (8023) 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
duration68.27 ± (68.31 - 68.55) ms68.57 ± (68.60 - 68.82) ms+0.4%✅⬆️
.NET Framework 4.8 - Bailout
duration72.30 ± (72.32 - 72.55) ms72.28 ± (72.17 - 72.38) ms-0.0%
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1002.91 ± (1004.44 - 1009.93) ms1003.26 ± (1005.14 - 1011.15) ms+0.0%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms21.95 ± (21.92 - 21.99) ms21.93 ± (21.90 - 21.96) ms-0.1%
process.time_to_main_ms78.49 ± (78.36 - 78.62) ms78.71 ± (78.56 - 78.85) ms+0.3%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.93 ± (10.92 - 10.93) MB10.92 ± (10.91 - 10.92) MB-0.1%
runtime.dotnet.threads.count12 ± (12 - 12)12 ± (12 - 12)+0.0%
.NET Core 3.1 - Bailout
process.internal_duration_ms21.91 ± (21.88 - 21.93) ms21.84 ± (21.82 - 21.87) ms-0.3%
process.time_to_main_ms79.69 ± (79.59 - 79.79) ms79.94 ± (79.85 - 80.02) ms+0.3%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.95 ± (10.95 - 10.95) MB10.96 ± (10.95 - 10.96) MB+0.1%✅⬆️
runtime.dotnet.threads.count13 ± (13 - 13)13 ± (13 - 13)+0.0%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms250.47 ± (246.56 - 254.38) ms249.23 ± (245.57 - 252.88) ms-0.5%
process.time_to_main_ms470.76 ± (470.25 - 471.26) ms471.53 ± (471.04 - 472.03) ms+0.2%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed48.17 ± (48.14 - 48.19) MB48.26 ± (48.23 - 48.28) MB+0.2%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)+0.1%✅⬆️
.NET 6 - Baseline
process.internal_duration_ms20.67 ± (20.64 - 20.70) ms20.65 ± (20.62 - 20.68) ms-0.1%
process.time_to_main_ms67.96 ± (67.86 - 68.06) ms68.28 ± (68.17 - 68.39) ms+0.5%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.62 ± (10.62 - 10.63) MB10.65 ± (10.65 - 10.65) MB+0.3%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 6 - Bailout
process.internal_duration_ms20.49 ± (20.47 - 20.51) ms20.67 ± (20.63 - 20.70) ms+0.9%✅⬆️
process.time_to_main_ms68.71 ± (68.66 - 68.76) ms69.48 ± (69.36 - 69.60) ms+1.1%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.68 ± (10.67 - 10.68) MB10.74 ± (10.74 - 10.75) MB+0.6%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms246.51 ± (244.39 - 248.63) ms248.68 ± (247.51 - 249.85) ms+0.9%✅⬆️
process.time_to_main_ms443.22 ± (442.57 - 443.87) ms440.90 ± (440.36 - 441.43) ms-0.5%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed48.72 ± (48.69 - 48.75) MB48.68 ± (48.65 - 48.72) MB-0.1%
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)-0.4%
.NET 8 - Baseline
process.internal_duration_ms18.90 ± (18.88 - 18.92) ms18.86 ± (18.83 - 18.89) ms-0.2%
process.time_to_main_ms67.38 ± (67.26 - 67.49) ms67.27 ± (67.19 - 67.36) ms-0.1%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.66 ± (7.66 - 7.67) MB7.70 ± (7.69 - 7.71) MB+0.5%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 8 - Bailout
process.internal_duration_ms18.90 ± (18.87 - 18.93) ms18.92 ± (18.89 - 18.95) ms+0.1%✅⬆️
process.time_to_main_ms68.32 ± (68.26 - 68.38) ms68.47 ± (68.42 - 68.53) ms+0.2%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.75 ± (7.74 - 7.77) MB7.73 ± (7.72 - 7.74) MB-0.3%
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms176.74 ± (175.90 - 177.58) ms177.82 ± (176.95 - 178.70) ms+0.6%✅⬆️
process.time_to_main_ms424.56 ± (424.07 - 425.04) ms425.90 ± (425.28 - 426.51) ms+0.3%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed36.35 ± (36.32 - 36.37) MB36.37 ± (36.34 - 36.41) MB+0.1%✅⬆️
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
duration193.61 ± (193.64 - 194.50) ms194.63 ± (194.61 - 195.49) ms+0.5%✅⬆️
.NET Framework 4.8 - Bailout
duration197.42 ± (197.12 - 197.91) ms197.07 ± (197.14 - 197.89) ms-0.2%
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1110.43 ± (1115.83 - 1129.36) ms1117.32 ± (1121.34 - 1130.93) ms+0.6%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms187.58 ± (187.16 - 188.00) ms188.83 ± (188.44 - 189.22) ms+0.7%✅⬆️
process.time_to_main_ms80.81 ± (80.57 - 81.05) ms80.89 ± (80.66 - 81.12) ms+0.1%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.11 ± (16.09 - 16.14) MB16.14 ± (16.11 - 16.17) MB+0.2%✅⬆️
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (20 - 20)-0.6%
.NET Core 3.1 - Bailout
process.internal_duration_ms186.90 ± (186.66 - 187.14) ms187.60 ± (187.27 - 187.94) ms+0.4%✅⬆️
process.time_to_main_ms81.86 ± (81.72 - 81.99) ms82.17 ± (82.01 - 82.32) ms+0.4%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.20 ± (16.17 - 16.23) MB16.14 ± (16.11 - 16.17) MB-0.4%
runtime.dotnet.threads.count21 ± (21 - 21)21 ± (21 - 21)+0.0%✅⬆️
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms425.89 ± (422.68 - 429.10) ms427.99 ± (425.15 - 430.83) ms+0.5%✅⬆️
process.time_to_main_ms471.90 ± (471.39 - 472.41) ms474.96 ± (474.35 - 475.57) ms+0.6%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed58.68 ± (58.57 - 58.80) MB58.79 ± (58.69 - 58.88) MB+0.2%✅⬆️
runtime.dotnet.threads.count29 ± (29 - 30)29 ± (29 - 30)-0.0%
.NET 6 - Baseline
process.internal_duration_ms193.09 ± (192.72 - 193.46) ms193.37 ± (192.91 - 193.84) ms+0.1%✅⬆️
process.time_to_main_ms69.99 ± (69.82 - 70.17) ms70.25 ± (70.08 - 70.41) ms+0.4%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.32 ± (16.25 - 16.38) MB16.32 ± (16.24 - 16.40) MB+0.0%✅⬆️
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)+0.8%✅⬆️
.NET 6 - Bailout
process.internal_duration_ms191.39 ± (191.07 - 191.71) ms192.87 ± (192.42 - 193.32) ms+0.8%✅⬆️
process.time_to_main_ms70.87 ± (70.75 - 70.99) ms71.35 ± (71.19 - 71.52) ms+0.7%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.10 ± (15.95 - 16.25) MB16.00 ± (15.84 - 16.15) MB-0.7%
runtime.dotnet.threads.count20 ± (20 - 20)19 ± (19 - 20)-2.3%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms455.81 ± (454.10 - 457.52) ms454.65 ± (452.32 - 456.98) ms-0.3%
process.time_to_main_ms446.19 ± (445.64 - 446.73) ms447.55 ± (447.04 - 448.06) ms+0.3%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed58.15 ± (58.03 - 58.27) MB58.20 ± (58.10 - 58.30) MB+0.1%✅⬆️
runtime.dotnet.threads.count30 ± (29 - 30)29 ± (29 - 30)-0.2%
.NET 8 - Baseline
process.internal_duration_ms189.71 ± (189.36 - 190.05) ms190.19 ± (189.82 - 190.56) ms+0.3%✅⬆️
process.time_to_main_ms69.19 ± (69.02 - 69.35) ms69.94 ± (69.71 - 70.18) ms+1.1%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.78 ± (11.75 - 11.81) MB11.78 ± (11.75 - 11.81) MB-0.0%
runtime.dotnet.threads.count18 ± (18 - 18)18 ± (18 - 18)+0.2%✅⬆️
.NET 8 - Bailout
process.internal_duration_ms190.23 ± (189.94 - 190.51) ms190.06 ± (189.77 - 190.35) ms-0.1%
process.time_to_main_ms70.67 ± (70.57 - 70.77) ms70.56 ± (70.45 - 70.67) ms-0.2%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.77 ± (11.74 - 11.81) MB11.76 ± (11.74 - 11.79) MB-0.1%
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)+0.3%✅⬆️
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms365.65 ± (363.86 - 367.44) ms363.29 ± (361.65 - 364.94) ms-0.6%
process.time_to_main_ms429.26 ± (428.75 - 429.76) ms430.09 ± (429.42 - 430.76) ms+0.2%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed47.95 ± (47.93 - 47.98) MB48.02 ± (47.99 - 48.05) MB+0.1%✅⬆️
runtime.dotnet.threads.count29 ± (29 - 29)29 ± (29 - 29)-0.2%
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 (8023) - mean (69ms)  : 67, 70
    master - mean (68ms)  : 67, 70

    section Bailout
    This PR (8023) - mean (72ms)  : 71, 73
    master - mean (72ms)  : 71, 74

    section CallTarget+Inlining+NGEN
    This PR (8023) - mean (1,008ms)  : 965, 1052
    master - mean (1,007ms)  : 968, 1047

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 (8023) - mean (106ms)  : 103, 110
    master - mean (106ms)  : 103, 109

    section Bailout
    This PR (8023) - mean (107ms)  : 106, 108
    master - mean (107ms)  : 105, 108

    section CallTarget+Inlining+NGEN
    This PR (8023) - mean (746ms)  : 692, 800
    master - mean (743ms)  : 680, 805

Loading
FakeDbCommand (.NET 6)
gantt
    title Execution time (ms) FakeDbCommand (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8023) - mean (94ms)  : 92, 96
    master - mean (93ms)  : 91, 96

    section Bailout
    This PR (8023) - mean (95ms)  : 93, 97
    master - mean (94ms)  : 93, 95

    section CallTarget+Inlining+NGEN
    This PR (8023) - mean (716ms)  : 682, 750
    master - mean (715ms)  : 682, 748

Loading
FakeDbCommand (.NET 8)
gantt
    title Execution time (ms) FakeDbCommand (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8023) - mean (92ms)  : 90, 94
    master - mean (92ms)  : 90, 94

    section Bailout
    This PR (8023) - mean (93ms)  : 92, 94
    master - mean (93ms)  : 92, 95

    section CallTarget+Inlining+NGEN
    This PR (8023) - mean (632ms)  : 617, 647
    master - mean (629ms)  : 615, 644

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 (8023) - mean (195ms)  : 190, 200
    master - mean (194ms)  : 190, 198

    section Bailout
    This PR (8023) - mean (198ms)  : 194, 201
    master - mean (198ms)  : 194, 201

    section CallTarget+Inlining+NGEN
    This PR (8023) - mean (1,126ms)  : 1057, 1196
    master - mean (1,123ms)  : 1045, 1201

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 (8023) - mean (278ms)  : 272, 284
    master - mean (277ms)  : 270, 283

    section Bailout
    This PR (8023) - mean (278ms)  : 274, 282
    master - mean (277ms)  : 274, 280

    section CallTarget+Inlining+NGEN
    This PR (8023) - mean (933ms)  : 889, 977
    master - mean (926ms)  : 877, 975

Loading
HttpMessageHandler (.NET 6)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8023) - mean (272ms)  : 265, 279
    master - mean (271ms)  : 266, 276

    section Bailout
    This PR (8023) - mean (272ms)  : 266, 278
    master - mean (270ms)  : 267, 274

    section CallTarget+Inlining+NGEN
    This PR (8023) - mean (930ms)  : 897, 964
    master - mean (931ms)  : 905, 958

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

    section Bailout
    This PR (8023) - mean (270ms)  : 267, 274
    master - mean (270ms)  : 267, 274

    section CallTarget+Inlining+NGEN
    This PR (8023) - mean (825ms)  : 803, 846
    master - mean (826ms)  : 805, 847

Loading

Copy link
Member

@andrewlock andrewlock left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM. I see a few more cases of this in the routing integration, wonder if we need to update those too?

@pr-commenter
Copy link

pr-commenter bot commented Dec 31, 2025

Benchmarks

Benchmark execution time: 2025-12-31 15:16:44

Comparing candidate commit 2441613 in PR branch steven/fix-null-ref-ipctcp with baseline commit 4fb09d3 in branch master.

Found 7 performance improvements and 8 performance regressions! Performance is the same for 155 metrics, 16 unstable metrics.

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody net472

  • 🟥 throughput [-7744.756op/s; -7394.953op/s] or [-6.002%; -5.731%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody netcoreapp3.1

  • 🟥 execution_time [+19.093ms; +23.281ms] or [+9.652%; +11.769%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net6.0

  • 🟩 execution_time [-79.854ms; -75.812ms] or [-41.703%; -39.592%]

scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice net6.0

  • 🟥 execution_time [+84.204µs; +92.423µs] or [+6.149%; +6.749%]
  • 🟥 throughput [-46.298op/s; -42.175op/s] or [-6.340%; -5.776%]

scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice netcoreapp3.1

  • 🟩 execution_time [-948.837µs; -695.550µs] or [-33.967%; -24.900%]

scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool net472

  • 🟥 execution_time [+70.921µs; +74.652µs] or [+6.214%; +6.541%]
  • 🟥 throughput [-53.888op/s; -51.185op/s] or [-6.150%; -5.841%]

scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool net6.0

  • 🟩 execution_time [-85.466µs; -79.294µs] or [-7.728%; -7.170%]
  • 🟩 throughput [+70.157op/s; +75.373op/s] or [+7.759%; +8.335%]

scenario:Benchmarks.Trace.DbCommandBenchmark.ExecuteNonQuery net6.0

  • 🟩 execution_time [-11.932ms; -10.728ms] or [-5.674%; -5.102%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch net472

  • 🟥 throughput [-17534.481op/s; -15484.932op/s] or [-6.036%; -5.330%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark net6.0

  • 🟥 throughput [-4127.971op/s; -2367.640op/s] or [-17.565%; -10.075%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog net472

  • 🟩 execution_time [-13.255ms; -12.738ms] or [-6.580%; -6.323%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog netcoreapp3.1

  • 🟩 throughput [+12797.684op/s; +15490.873op/s] or [+7.804%; +9.446%]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants