Add benchmarks for single-span diagnostic observer for ASP.NET Core#7965
Merged
andrewlock merged 2 commits intomasterfrom Jan 13, 2026
Merged
Add benchmarks for single-span diagnostic observer for ASP.NET Core#7965andrewlock merged 2 commits intomasterfrom
andrewlock merged 2 commits intomasterfrom
Conversation
bac154e to
395dce4
Compare
This was referenced Dec 17, 2025
This comment has been minimized.
This comment has been minimized.
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (7965) and master. ✅ No regressions detected - check the details below Full Metrics ComparisonFakeDbCommand
HttpMessageHandler
Comparison explanationExecution-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:
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 chartsFakeDbCommand (.NET Framework 4.8)gantt
title Execution time (ms) FakeDbCommand (.NET Framework 4.8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7965) - mean (78ms) : 74, 81
master - mean (78ms) : 75, 82
section Bailout
This PR (7965) - mean (82ms) : 79, 85
master - mean (82ms) : 79, 84
section CallTarget+Inlining+NGEN
This PR (7965) - mean (1,083ms) : 1033, 1133
master - mean (1,090ms) : 1047, 1132
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 (7965) - mean (121ms) : 116, 126
master - mean (119ms) : 115, 123
section Bailout
This PR (7965) - mean (123ms) : 118, 128
master - mean (121ms) : 118, 124
section CallTarget+Inlining+NGEN
This PR (7965) - mean (791ms) : 719, 863
master - mean (797ms) : 737, 858
FakeDbCommand (.NET 6)gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7965) - mean (106ms) : 103, 110
master - mean (106ms) : 103, 109
section Bailout
This PR (7965) - mean (107ms) : 105, 109
master - mean (107ms) : 104, 110
section CallTarget+Inlining+NGEN
This PR (7965) - mean (764ms) : 695, 834
master - mean (769ms) : 691, 847
FakeDbCommand (.NET 8)gantt
title Execution time (ms) FakeDbCommand (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7965) - mean (105ms) : 101, 109
master - mean (105ms) : 102, 109
section Bailout
This PR (7965) - mean (106ms) : 103, 109
master - mean (107ms) : 104, 109
section CallTarget+Inlining+NGEN
This PR (7965) - mean (696ms) : 675, 717
master - mean (703ms) : 676, 731
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 (7965) - mean (196ms) : 191, 202
master - mean (195ms) : 191, 199
section Bailout
This PR (7965) - mean (200ms) : 195, 205
master - mean (199ms) : 195, 204
section CallTarget+Inlining+NGEN
This PR (7965) - mean (1,145ms) : 1082, 1207
master - mean (1,144ms) : 1053, 1234
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 (7965) - mean (281ms) : 276, 287
master - mean (282ms) : 271, 293
section Bailout
This PR (7965) - mean (285ms) : 276, 293
master - mean (281ms) : 274, 287
section CallTarget+Inlining+NGEN
This PR (7965) - mean (956ms) : 899, 1012
master - mean (943ms) : 907, 979
HttpMessageHandler (.NET 6)gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7965) - mean (278ms) : 268, 287
master - mean (273ms) : 267, 280
section Bailout
This PR (7965) - mean (278ms) : 267, 289
master - mean (273ms) : 267, 279
section CallTarget+Inlining+NGEN
This PR (7965) - mean (951ms) : 901, 1001
master - mean (936ms) : 899, 973
HttpMessageHandler (.NET 8)gantt
title Execution time (ms) HttpMessageHandler (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7965) - mean (274ms) : 267, 281
master - mean (274ms) : 266, 282
section Bailout
This PR (7965) - mean (276ms) : 266, 286
master - mean (272ms) : 267, 276
section CallTarget+Inlining+NGEN
This PR (7965) - mean (850ms) : 810, 891
master - mean (847ms) : 816, 878
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
395dce4 to
b70c982
Compare
c2c2b8c to
37760e4
Compare
b70c982 to
d534f1e
Compare
37760e4 to
65dcd0e
Compare
lucaspimentel
approved these changes
Dec 19, 2025
andrewlock
added a commit
that referenced
this pull request
Dec 23, 2025
## Summary of changes Adds a `ValueStringBuilder` implementation, based on the one used internally in the .NET runtime ## Reason for change - We can stackalloc the `Span<char>` - It's a bit faster than our existing `StringBuilderCache` implementation, and in some places that matters. ## Implementation details - Made in .NET 6 only for simplicity. We _could_ expose it earlier, but I wanted this for the updated aspnetcore integration, so .NET6+ only for now is good enough - It's not without risks in its usage, so we have to be careful about things like passing it around (i.e. avoid doing that completely, for safety) - Uses an array pool backed implementation (again, built into .NET 6) ## Test coverage Imported the unit tests from the runtime too ## Other details https://datadoghq.atlassian.net/browse/LANGPLAT-842 Part of a stack - #7962 👈 - #7963 - #7964 - #7966 - #7965
d534f1e to
199b720
Compare
65dcd0e to
303a7ac
Compare
199b720 to
acca38c
Compare
303a7ac to
8a6357a
Compare
andrewlock
added a commit
that referenced
this pull request
Dec 24, 2025
## Summary of changes Small perf tweaks for existing `AspNetCoreDiagnosticObserver` ## Reason for change While experimenting with single span observer, noticed some (safe) tweaks we could make to the existing implementation. There are some other improvements we could make as well, but those are a little riskier, so may be best to delay them. ## Implementation details - Use `HttpContext.Items[string]` instead of `HttpContext.Features.Get<T>` as it's a bit faster - Make `Tracer`/`Security`/`Iast` inputs readonly, instead of using a null-coalesce with every access - Move check outside of `AddHeaderTagsToSpan` given common case is to avoid the function call ## Test coverage Covered by existing tests ## Other details https://datadoghq.atlassian.net/browse/LANGPLAT-842 Part of a stack - #7962 - #7963 👈 - #7964 - #7966 - #7965
acca38c to
28a568e
Compare
8a6357a to
4fd083f
Compare
28a568e to
80402b7
Compare
4fd083f to
5d97960
Compare
80402b7 to
ac67c63
Compare
5d97960 to
67ea0dd
Compare
andrewlock
added a commit
that referenced
this pull request
Jan 13, 2026
## Summary of changes Adds a new `DD_TRACE_SINGLE_SPAN_ASPNETCORE_ENABLED` in which we omit the MVC span ## Reason for change - Addresses #4093 and partially #1147 - Omitting the MVC span has perf and some usability benefits in some cases (See issues above). It _does_ mean a certain amount of less information, particularly in pipeline re-execution scenarios ## Implementation details - Add a new, disabled by default, `DD_TRACE_SINGLE_SPAN_ASPNETCORE_ENABLED` for opting in to the new behaviour. - .NET 6+ only for various reasons - Cloned the original observer, deleted everything related to the MVC span, and then optimized further based on .NET 6+ and other improvements we can make ## Test coverage - Added in-process "integration" tests for the observer (more like unit tests), which mirror the exisitng. - Added "full" sample-based integration tests for basically all scenarios we currently test (IIS in process/out of process / MVC / minimal APIs / proxy spans etc) - Added snapshots by copying existing, and then updating, so if you look at the final commit, you can see the diff, which is basically just "delete the child span" ## Other details https://datadoghq.atlassian.net/browse/LANGPLAT-842 Part of a stack - #7962 - #7963 - #7964 👈 - #7966 - #7965 I experimented with some other perf improvements, but they didn't provide a significant improvement, so I reverted: - Caching the resource name by saving it into the `IEndpointMetadata` collection. The work to do that was too much, and you _can't_ cache in some cases anyway so not worth it - Splitting `WebTags` out to remove the IP headers unless we need them. They're disabled by default, so it just increase the size of the tags object, but wasn't a big enough improvement to make the complexity worth it. - Tried pooling the `RequestTrackingFeature` objects. This one _may_ actually be worth exploring again later, but I didn't see any improvement in my testing, as they're just not very big and only last 1 request. --------- Co-authored-by: Lucas Pimentel <lucas.pimentel@datadoghq.com>
67ea0dd to
2ce366f
Compare
ac67c63 to
b7f19f3
Compare
andrewlock
added a commit
that referenced
this pull request
Jan 13, 2026
## Summary of changes Creates an optimized version of `AspNetCoreResourceNameHelper` for use by the single-span Diagnostic observer. ## Reason for change We have the opportunity for a variety of optimizations thanks to not creating the MVC span, and the fact that we're .NET 6+. We could potentially include some or all of these optimizations in the existing observer path, but for safety/simplicity I'd rather keep it isolated for now, and we can look at expanding it more broadly later ## Implementation details - Use the `ValueStringBuilder` to build a resource name - Don't pre-grab MVC route values, wait to see if we have route params from them first - Write directly into the builder as `ToLowerInvariant`, instead of doing an extra ToLower() at the end ## Test coverage Added unit tests that use the existing data for the other implementations, to confirm it's identical. It's also covered indirectly by the integration tests ## Other details https://datadoghq.atlassian.net/browse/LANGPLAT-842 Part of a stack - #7962 - #7963 - #7964 - #7966 👈 - #7965
Merged
andrewlock
added a commit
that referenced
this pull request
Jan 14, 2026
## Summary of changes Fixes the broken build in the benchmarks ## Reason for change #7965 broke the benchmark build for some TFMs. I think the race condition between creating a PR and running the benchmarks meant we didn't notice the failure, especially because the run still took 30+ mins because it worked in _some_ TFMs ## Implementation details - Ensure we have the dummy benchmark for TFMs that don't support it - Fix some minor spurious warnings ## Test coverage This is the test, I'll carefully check the run this time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of changes
Adds a micro and macro benchmark for the new observer
Reason for change
Want to verify that it has performance benefits
Implementation details
Test coverage
I'll manually trigger a run of the macro
Other details
https://datadoghq.atlassian.net/browse/LANGPLAT-842
Part of a stack
ValueStringBuilderfor .NET 6 #7962AspNetCoreDiagnosticObserver#7963AspNetCoreResourceNameHelper#7966