-
Notifications
You must be signed in to change notification settings - Fork 151
Restructure RuntimeMetricsWriter for .NET Framework to fix StackOverflowException
#7830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Restructure RuntimeMetricsWriter for .NET Framework to fix StackOverflowException
#7830
Conversation
There was a problem hiding this 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".
30045c7 to
7ac1ff6
Compare
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (7830) 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 (7830) - mean (76ms) : 70, 82
master - mean (76ms) : 71, 81
section Bailout
This PR (7830) - mean (80ms) : 74, 87
master - mean (80ms) : 74, 86
section CallTarget+Inlining+NGEN
This PR (7830) - mean (1,131ms) : 1041, 1221
master - mean (1,126ms) : 1057, 1196
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 (7830) - mean (120ms) : 111, 129
master - mean (118ms) : 111, 124
section Bailout
This PR (7830) - mean (120ms) : 112, 127
master - mean (120ms) : 112, 128
section CallTarget+Inlining+NGEN
This PR (7830) - mean (816ms) : 772, 861
master - mean (804ms) : 757, 851
FakeDbCommand (.NET 6)gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7830) - mean (108ms) : 101, 115
master - mean (108ms) : 100, 115
section Bailout
This PR (7830) - mean (107ms) : 100, 115
master - mean (108ms) : 100, 115
section CallTarget+Inlining+NGEN
This PR (7830) - mean (753ms) : 711, 795
master - mean (756ms) : 722, 789
FakeDbCommand (.NET 8)gantt
title Execution time (ms) FakeDbCommand (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7830) - mean (106ms) : 98, 113
master - mean (104ms) : 97, 112
section Bailout
This PR (7830) - mean (106ms) : 99, 114
master - mean (105ms) : 98, 112
section CallTarget+Inlining+NGEN
This PR (7830) - mean (718ms) : 688, 748
master - mean (719ms) : 688, 750
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 (7830) - mean (196ms) : 188, 203
master - mean (194ms) : 189, 199
section Bailout
This PR (7830) - mean (200ms) : 191, 209
master - mean (198ms) : 193, 202
section CallTarget+Inlining+NGEN
This PR (7830) - mean (1,193ms) : 1105, 1282
master - mean (1,176ms) : 1103, 1249
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 (7830) - mean (283ms) : 274, 292
master - mean (277ms) : 272, 283
section Bailout
This PR (7830) - mean (281ms) : 273, 290
master - mean (278ms) : 273, 282
section CallTarget+Inlining+NGEN
This PR (7830) - mean (960ms) : 915, 1005
master - mean (942ms) : 905, 980
HttpMessageHandler (.NET 6)gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7830) - mean (271ms) : 265, 278
master - mean (271ms) : 265, 277
section Bailout
This PR (7830) - mean (272ms) : 266, 278
master - mean (270ms) : 267, 273
section CallTarget+Inlining+NGEN
This PR (7830) - mean (936ms) : 884, 987
master - mean (937ms) : 888, 986
HttpMessageHandler (.NET 8)gantt
title Execution time (ms) HttpMessageHandler (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7830) - mean (270ms) : 265, 276
master - mean (274ms) : 261, 288
section Bailout
This PR (7830) - mean (272ms) : 265, 280
master - mean (273ms) : 266, 280
section CallTarget+Inlining+NGEN
This PR (7830) - mean (855ms) : 833, 877
master - mean (870ms) : 846, 895
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
BenchmarksBenchmarks Report for benchmark platform 🐌Benchmarks for #7830 compared to master:
The following thresholds were used for comparing the benchmark speeds:
Allocation changes below 0.5% are ignored. Benchmark detailsBenchmarks.Trace.ActivityBenchmark - Same speed ✔️ More allocations
|
| Benchmark | Base Allocated | Diff Allocated | Change | Change % |
|---|---|---|---|---|
| Benchmarks.Trace.ActivityBenchmark.StartStopWithChild‑net6.0 | 5.49 KB | 5.52 KB | 32 B | 0.58% |
| Benchmark | Base Allocated | Diff Allocated | Change | Change % |
|---|---|---|---|---|
| Benchmarks.Trace.ActivityBenchmark.StartStopWithChild‑netcoreapp3.1 | 5.77 KB | 5.73 KB | -45 B | -0.78% |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | StartStopWithChild |
net6.0 | 10.4μs | 58.6ns | 380ns | 0 | 0 | 0 | 5.49 KB |
| master | StartStopWithChild |
netcoreapp3.1 | 13.3μs | 67.3ns | 301ns | 0 | 0 | 0 | 5.77 KB |
| master | StartStopWithChild |
net472 | 21.8μs | 103ns | 439ns | 1.03 | 0.343 | 0.114 | 6.08 KB |
| #7830 | StartStopWithChild |
net6.0 | 10.7μs | 55.5ns | 277ns | 0 | 0 | 0 | 5.52 KB |
| #7830 | StartStopWithChild |
netcoreapp3.1 | 13.9μs | 70.1ns | 321ns | 0 | 0 | 0 | 5.73 KB |
| #7830 | StartStopWithChild |
net472 | 22μs | 121ns | 727ns | 0.985 | 0.438 | 0.109 | 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 | 932μs | 145ns | 562ns | 0 | 0 | 0 | 2.7 KB |
| master | WriteAndFlushEnrichedTraces |
netcoreapp3.1 | 1.04ms | 40.2ns | 145ns | 0 | 0 | 0 | 2.7 KB |
| master | WriteAndFlushEnrichedTraces |
net472 | 1.21ms | 114ns | 441ns | 0 | 0 | 0 | 3.31 KB |
| #7830 | WriteAndFlushEnrichedTraces |
net6.0 | 917μs | 94.1ns | 339ns | 0 | 0 | 0 | 2.7 KB |
| #7830 | WriteAndFlushEnrichedTraces |
netcoreapp3.1 | 1.07ms | 581ns | 2.1μs | 0 | 0 | 0 | 2.7 KB |
| #7830 | WriteAndFlushEnrichedTraces |
net472 | 1.21ms | 925ns | 3.21μs | 0 | 0 | 0 | 3.31 KB |
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.06μs | 5.5ns | 28ns | 0 | 0 | 0 | 1.22 KB |
| master | AllCycleSimpleBody |
netcoreapp3.1 | 1.44μs | 7.14ns | 31.9ns | 0 | 0 | 0 | 1.2 KB |
| master | AllCycleSimpleBody |
net472 | 1μs | 0.315ns | 1.18ns | 0.192 | 0 | 0 | 1.23 KB |
| master | AllCycleMoreComplexBody |
net6.0 | 7.07μs | 36.6ns | 175ns | 0 | 0 | 0 | 4.72 KB |
| master | AllCycleMoreComplexBody |
netcoreapp3.1 | 9.09μs | 43.6ns | 180ns | 0 | 0 | 0 | 4.62 KB |
| master | AllCycleMoreComplexBody |
net472 | 7.57μs | 2.65ns | 10.2ns | 0.716 | 0 | 0 | 4.74 KB |
| master | ObjectExtractorSimpleBody |
net6.0 | 325ns | 1.78ns | 9.75ns | 0 | 0 | 0 | 280 B |
| master | ObjectExtractorSimpleBody |
netcoreapp3.1 | 401ns | 1.93ns | 8.21ns | 0 | 0 | 0 | 272 B |
| master | ObjectExtractorSimpleBody |
net472 | 294ns | 0.0375ns | 0.14ns | 0.0444 | 0 | 0 | 281 B |
| master | ObjectExtractorMoreComplexBody |
net6.0 | 6.3μs | 30ns | 120ns | 0 | 0 | 0 | 3.78 KB |
| master | ObjectExtractorMoreComplexBody |
netcoreapp3.1 | 7.81μs | 22.7ns | 88ns | 0 | 0 | 0 | 3.69 KB |
| master | ObjectExtractorMoreComplexBody |
net472 | 6.62μs | 3.58ns | 13.9ns | 0.598 | 0 | 0 | 3.8 KB |
| #7830 | AllCycleSimpleBody |
net6.0 | 1.09μs | 4.42ns | 17.1ns | 0 | 0 | 0 | 1.22 KB |
| #7830 | AllCycleSimpleBody |
netcoreapp3.1 | 1.39μs | 7.66ns | 47.8ns | 0 | 0 | 0 | 1.2 KB |
| #7830 | AllCycleSimpleBody |
net472 | 1.03μs | 5.21ns | 23.9ns | 0.193 | 0 | 0 | 1.23 KB |
| #7830 | AllCycleMoreComplexBody |
net6.0 | 7.18μs | 38.1ns | 194ns | 0 | 0 | 0 | 4.72 KB |
| #7830 | AllCycleMoreComplexBody |
netcoreapp3.1 | 8.9μs | 40.1ns | 155ns | 0 | 0 | 0 | 4.62 KB |
| #7830 | AllCycleMoreComplexBody |
net472 | 7.69μs | 5.14ns | 19.2ns | 0.73 | 0 | 0 | 4.74 KB |
| #7830 | ObjectExtractorSimpleBody |
net6.0 | 327ns | 0.567ns | 2.12ns | 0 | 0 | 0 | 280 B |
| #7830 | ObjectExtractorSimpleBody |
netcoreapp3.1 | 403ns | 2.26ns | 15ns | 0 | 0 | 0 | 272 B |
| #7830 | ObjectExtractorSimpleBody |
net472 | 301ns | 0.0275ns | 0.106ns | 0.044 | 0 | 0 | 281 B |
| #7830 | ObjectExtractorMoreComplexBody |
net6.0 | 6.37μs | 32.9ns | 165ns | 0 | 0 | 0 | 3.79 KB |
| #7830 | ObjectExtractorMoreComplexBody |
netcoreapp3.1 | 7.8μs | 27.1ns | 105ns | 0 | 0 | 0 | 3.69 KB |
| #7830 | ObjectExtractorMoreComplexBody |
net472 | 6.67μs | 2.17ns | 8.41ns | 0.602 | 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 | 77.3μs | 245ns | 884ns | 0 | 0 | 0 | 32.4 KB |
| master | EncodeArgs |
netcoreapp3.1 | 98.2μs | 273ns | 1.06μs | 0 | 0 | 0 | 32.4 KB |
| master | EncodeArgs |
net472 | 109μs | 30.5ns | 118ns | 4.92 | 0 | 0 | 32.51 KB |
| master | EncodeLegacyArgs |
net6.0 | 146μs | 30ns | 112ns | 0 | 0 | 0 | 2.15 KB |
| master | EncodeLegacyArgs |
netcoreapp3.1 | 198μs | 206ns | 798ns | 0 | 0 | 0 | 2.14 KB |
| master | EncodeLegacyArgs |
net472 | 263μs | 32.5ns | 126ns | 0 | 0 | 0 | 2.16 KB |
| #7830 | EncodeArgs |
net6.0 | 77.3μs | 12.5ns | 46.6ns | 0 | 0 | 0 | 32.4 KB |
| #7830 | EncodeArgs |
netcoreapp3.1 | 97.5μs | 279ns | 1.08μs | 0 | 0 | 0 | 32.4 KB |
| #7830 | EncodeArgs |
net472 | 109μs | 12.4ns | 48.2ns | 4.9 | 0 | 0 | 32.51 KB |
| #7830 | EncodeLegacyArgs |
net6.0 | 145μs | 40.7ns | 152ns | 0 | 0 | 0 | 2.14 KB |
| #7830 | EncodeLegacyArgs |
netcoreapp3.1 | 197μs | 140ns | 541ns | 0 | 0 | 0 | 2.14 KB |
| #7830 | EncodeLegacyArgs |
net472 | 263μs | 52ns | 188ns | 0 | 0 | 0 | 2.16 KB |
Benchmarks.Trace.Asm.AppSecWafBenchmark - Slower ⚠️ Same allocations ✔️
Slower ⚠️ in #7830
Benchmark
diff/base
Base Median (ns)
Diff Median (ns)
Modality
Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark‑netcoreapp3.1
1.494
419,058.75
625,886.88
Faster 🎉 in #7830
Benchmark
base/diff
Base Median (ns)
Diff Median (ns)
Modality
Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack‑netcoreapp3.1
1.707
508,311.74
297,867.86
| Benchmark | diff/base | Base Median (ns) | Diff Median (ns) | Modality |
|---|---|---|---|---|
| Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark‑netcoreapp3.1 | 1.494 | 419,058.75 | 625,886.88 |
| Benchmark | base/diff | Base Median (ns) | Diff Median (ns) | Modality |
|---|---|---|---|---|
| Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack‑netcoreapp3.1 | 1.707 | 508,311.74 | 297,867.86 |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | RunWafRealisticBenchmark |
net6.0 | 392μs | 67.4ns | 261ns | 0 | 0 | 0 | 4.56 KB |
| master | RunWafRealisticBenchmark |
netcoreapp3.1 | 419μs | 132ns | 476ns | 0 | 0 | 0 | 4.48 KB |
| master | RunWafRealisticBenchmark |
net472 | 430μs | 60.1ns | 225ns | 0 | 0 | 0 | 4.66 KB |
| master | RunWafRealisticBenchmarkWithAttack |
net6.0 | 285μs | 22.4ns | 86.8ns | 0 | 0 | 0 | 2.24 KB |
| master | RunWafRealisticBenchmarkWithAttack |
netcoreapp3.1 | 504μs | 2.93μs | 26.7μs | 0 | 0 | 0 | 2.22 KB |
| master | RunWafRealisticBenchmarkWithAttack |
net472 | 311μs | 41.8ns | 162ns | 0 | 0 | 0 | 2.29 KB |
| #7830 | RunWafRealisticBenchmark |
net6.0 | 397μs | 66.6ns | 249ns | 0 | 0 | 0 | 4.56 KB |
| #7830 | RunWafRealisticBenchmark |
netcoreapp3.1 | 619μs | 3.82μs | 38μs | 0 | 0 | 0 | 4.48 KB |
| #7830 | RunWafRealisticBenchmark |
net472 | 429μs | 51.2ns | 198ns | 0 | 0 | 0 | 4.68 KB |
| #7830 | RunWafRealisticBenchmarkWithAttack |
net6.0 | 282μs | 22.2ns | 76.8ns | 0 | 0 | 0 | 2.24 KB |
| #7830 | RunWafRealisticBenchmarkWithAttack |
netcoreapp3.1 | 298μs | 194ns | 726ns | 0 | 0 | 0 | 2.22 KB |
| #7830 | RunWafRealisticBenchmarkWithAttack |
net472 | 308μs | 19.4ns | 72.6ns | 0 | 0 | 0 | 2.29 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 | 61.2μs | 80.5ns | 301ns | 0 | 0 | 0 | 14.52 KB |
| master | SendRequest |
netcoreapp3.1 | 70.8μs | 60.5ns | 210ns | 0 | 0 | 0 | 17.42 KB |
| master | SendRequest |
net472 | 0.0147ns | 0.00305ns | 0.0118ns | 0 | 0 | 0 | 0 b |
| #7830 | SendRequest |
net6.0 | 62.1μs | 189ns | 730ns | 0 | 0 | 0 | 14.52 KB |
| #7830 | SendRequest |
netcoreapp3.1 | 71.5μs | 45.8ns | 171ns | 0 | 0 | 0 | 17.42 KB |
| #7830 | SendRequest |
net472 | 0.00886ns | 0.00333ns | 0.0129ns | 0 | 0 | 0 | 0 b |
Benchmarks.Trace.CharSliceBenchmark - Same speed ✔️ More allocations ⚠️
More allocations ⚠️ in #7830
Benchmark
Base Allocated
Diff Allocated
Change
Change %
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool‑net6.0
3 B
5 B
2 B
66.67%
Fewer allocations 🎉 in #7830
Benchmark
Base Allocated
Diff Allocated
Change
Change %
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice‑net6.0
4 B
2 B
-2 B
-50.00%
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool‑netcoreapp3.1
16 B
1 B
-15 B
-93.75%
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice‑net472
73 B
0 b
-73 B
-100.00%
Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool‑net472
47 B
0 b
-47 B
-100.00%
| Benchmark | Base Allocated | Diff Allocated | Change | Change % |
|---|---|---|---|---|
| Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool‑net6.0 | 3 B | 5 B | 2 B | 66.67% |
| Benchmark | Base Allocated | Diff Allocated | Change | Change % |
|---|---|---|---|---|
| Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice‑net6.0 | 4 B | 2 B | -2 B | -50.00% |
| Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool‑netcoreapp3.1 | 16 B | 1 B | -15 B | -93.75% |
| Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice‑net472 | 73 B | 0 b | -73 B | -100.00% |
| Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool‑net472 | 47 B | 0 b | -47 B | -100.00% |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | OriginalCharSlice |
net6.0 | 1.92ms | 953ns | 3.69μs | 0 | 0 | 0 | 640.01 KB |
| master | OriginalCharSlice |
netcoreapp3.1 | 2.16ms | 10.6μs | 42.3μs | 0 | 0 | 0 | 640 KB |
| master | OriginalCharSlice |
net472 | 2.59ms | 161ns | 582ns | 100 | 0 | 0 | 641.95 KB |
| master | OptimizedCharSlice |
net6.0 | 1.39ms | 530ns | 2.05μs | 0 | 0 | 0 | 4 B |
| master | OptimizedCharSlice |
netcoreapp3.1 | 1.71ms | 484ns | 1.87μs | 0 | 0 | 0 | 1 B |
| master | OptimizedCharSlice |
net472 | 1.97ms | 1.62μs | 6.26μs | 0 | 0 | 0 | 73 B |
| master | OptimizedCharSliceWithPool |
net6.0 | 851μs | 33.4ns | 129ns | 0 | 0 | 0 | 3 B |
| master | OptimizedCharSliceWithPool |
netcoreapp3.1 | 809μs | 255ns | 987ns | 0 | 0 | 0 | 16 B |
| master | OptimizedCharSliceWithPool |
net472 | 1.16ms | 105ns | 393ns | 0 | 0 | 0 | 47 B |
| #7830 | OriginalCharSlice |
net6.0 | 1.91ms | 3.95μs | 15.3μs | 0 | 0 | 0 | 640.01 KB |
| #7830 | OriginalCharSlice |
netcoreapp3.1 | 2.08ms | 5.4μs | 20.9μs | 0 | 0 | 0 | 640 KB |
| #7830 | OriginalCharSlice |
net472 | 2.63ms | 1.21μs | 4.55μs | 100 | 0 | 0 | 641.95 KB |
| #7830 | OptimizedCharSlice |
net6.0 | 1.36ms | 93.8ns | 363ns | 0 | 0 | 0 | 2 B |
| #7830 | OptimizedCharSlice |
netcoreapp3.1 | 1.65ms | 418ns | 1.62μs | 0 | 0 | 0 | 1 B |
| #7830 | OptimizedCharSlice |
net472 | 2.01ms | 811ns | 3.14μs | 0 | 0 | 0 | 0 b |
| #7830 | OptimizedCharSliceWithPool |
net6.0 | 839μs | 32.3ns | 125ns | 0 | 0 | 0 | 5 B |
| #7830 | OptimizedCharSliceWithPool |
netcoreapp3.1 | 815μs | 46ns | 178ns | 0 | 0 | 0 | 1 B |
| #7830 | OptimizedCharSliceWithPool |
net472 | 1.19ms | 134ns | 519ns | 0 | 0 | 0 | 0 b |
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ More allocations ⚠️
More allocations ⚠️ in #7830
Benchmark
Base Allocated
Diff Allocated
Change
Change %
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑netcoreapp3.1
41.86 KB
42.09 KB
228 B
0.54%
| Benchmark | Base Allocated | Diff Allocated | Change | Change % |
|---|---|---|---|---|
| Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑netcoreapp3.1 | 41.86 KB | 42.09 KB | 228 B | 0.54% |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | WriteAndFlushEnrichedTraces |
net6.0 | 670μs | 1.56μs | 6.02μs | 0 | 0 | 0 | 41.85 KB |
| master | WriteAndFlushEnrichedTraces |
netcoreapp3.1 | 747μs | 3.69μs | 16.1μs | 0 | 0 | 0 | 41.86 KB |
| master | WriteAndFlushEnrichedTraces |
net472 | 877μs | 1.68μs | 6.49μs | 8.33 | 0 | 0 | 56.15 KB |
| #7830 | WriteAndFlushEnrichedTraces |
net6.0 | 669μs | 640ns | 2.48μs | 0 | 0 | 0 | 41.99 KB |
| #7830 | WriteAndFlushEnrichedTraces |
netcoreapp3.1 | 698μs | 3.65μs | 18.3μs | 0 | 0 | 0 | 42.09 KB |
| #7830 | WriteAndFlushEnrichedTraces |
net472 | 973μs | 3.22μs | 12.5μs | 4.81 | 0 | 0 | 55.96 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.9μs | 3.53ns | 13.7ns | 0 | 0 | 0 | 1.02 KB |
| master | ExecuteNonQuery |
netcoreapp3.1 | 2.58μs | 9.58ns | 37.1ns | 0 | 0 | 0 | 1.02 KB |
| master | ExecuteNonQuery |
net472 | 2.92μs | 6.05ns | 23.4ns | 0.145 | 0.0145 | 0 | 987 B |
| #7830 | ExecuteNonQuery |
net6.0 | 1.95μs | 5.74ns | 21.5ns | 0 | 0 | 0 | 1.02 KB |
| #7830 | ExecuteNonQuery |
netcoreapp3.1 | 2.66μs | 7.07ns | 27.4ns | 0 | 0 | 0 | 1.02 KB |
| #7830 | ExecuteNonQuery |
net472 | 2.8μs | 3.56ns | 13.8ns | 0.152 | 0.0139 | 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.75μs | 8.85ns | 41.5ns | 0 | 0 | 0 | 1.03 KB |
| master | CallElasticsearch |
netcoreapp3.1 | 2.25μs | 3.56ns | 13.3ns | 0 | 0 | 0 | 1.03 KB |
| master | CallElasticsearch |
net472 | 3.55μs | 9.71ns | 37.6ns | 0.159 | 0 | 0 | 1.04 KB |
| master | CallElasticsearchAsync |
net6.0 | 1.8μs | 0.798ns | 3.09ns | 0 | 0 | 0 | 1.01 KB |
| master | CallElasticsearchAsync |
netcoreapp3.1 | 2.42μs | 11.8ns | 47.1ns | 0 | 0 | 0 | 1.08 KB |
| master | CallElasticsearchAsync |
net472 | 3.79μs | 5.21ns | 20.2ns | 0.17 | 0 | 0 | 1.1 KB |
| #7830 | CallElasticsearch |
net6.0 | 1.71μs | 6.27ns | 23.5ns | 0 | 0 | 0 | 1.03 KB |
| #7830 | CallElasticsearch |
netcoreapp3.1 | 2.23μs | 11.1ns | 48.3ns | 0 | 0 | 0 | 1.03 KB |
| #7830 | CallElasticsearch |
net472 | 3.43μs | 2.94ns | 11.4ns | 0.155 | 0 | 0 | 1.04 KB |
| #7830 | CallElasticsearchAsync |
net6.0 | 1.86μs | 0.549ns | 2.13ns | 0 | 0 | 0 | 1.01 KB |
| #7830 | CallElasticsearchAsync |
netcoreapp3.1 | 2.34μs | 11.7ns | 49.8ns | 0 | 0 | 0 | 1.08 KB |
| #7830 | CallElasticsearchAsync |
net472 | 3.59μs | 2.8ns | 10.8ns | 0.162 | 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.83μs | 2.89ns | 11.2ns | 0 | 0 | 0 | 952 B |
| master | ExecuteAsync |
netcoreapp3.1 | 2.47μs | 11.3ns | 43.9ns | 0 | 0 | 0 | 952 B |
| master | ExecuteAsync |
net472 | 2.58μs | 1.95ns | 7.29ns | 0.142 | 0 | 0 | 915 B |
| #7830 | ExecuteAsync |
net6.0 | 1.88μs | 9.45ns | 41.2ns | 0 | 0 | 0 | 952 B |
| #7830 | ExecuteAsync |
netcoreapp3.1 | 2.44μs | 7.63ns | 29.5ns | 0 | 0 | 0 | 952 B |
| #7830 | ExecuteAsync |
net472 | 2.64μs | 4.65ns | 18ns | 0.144 | 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 | 7.06μs | 18ns | 69.7ns | 0 | 0 | 0 | 2.36 KB |
| master | SendAsync |
netcoreapp3.1 | 8.69μs | 22.9ns | 88.6ns | 0 | 0 | 0 | 2.9 KB |
| master | SendAsync |
net472 | 12.4μs | 7.92ns | 30.7ns | 0.496 | 0 | 0 | 3.18 KB |
| #7830 | SendAsync |
net6.0 | 7.25μs | 14.9ns | 55.9ns | 0 | 0 | 0 | 2.36 KB |
| #7830 | SendAsync |
netcoreapp3.1 | 8.52μs | 36.6ns | 142ns | 0 | 0 | 0 | 2.9 KB |
| #7830 | SendAsync |
net472 | 12.2μs | 9.71ns | 35ns | 0.488 | 0 | 0 | 3.18 KB |
Benchmarks.Trace.Iast.StringAspectsBenchmark - Same speed ✔️ More allocations ⚠️
More allocations ⚠️ in #7830
Benchmark
Base Allocated
Diff Allocated
Change
Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑netcoreapp3.1
255.29 KB
257.68 KB
2.39 KB
0.94%
Fewer allocations 🎉 in #7830
Benchmark
Base Allocated
Diff Allocated
Change
Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net6.0
44.32 KB
43.89 KB
-432 B
-0.97%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net472
286.72 KB
278.53 KB
-8.19 KB
-2.86%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net472
65.54 KB
57.34 KB
-8.19 KB
-12.50%
| Benchmark | Base Allocated | Diff Allocated | Change | Change % |
|---|---|---|---|---|
| Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑netcoreapp3.1 | 255.29 KB | 257.68 KB | 2.39 KB | 0.94% |
| Benchmark | Base Allocated | Diff Allocated | Change | Change % |
|---|---|---|---|---|
| Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net6.0 | 44.32 KB | 43.89 KB | -432 B | -0.97% |
| Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net472 | 286.72 KB | 278.53 KB | -8.19 KB | -2.86% |
| Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net472 | 65.54 KB | 57.34 KB | -8.19 KB | -12.50% |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | StringConcatBenchmark |
net6.0 | 44.3μs | 213ns | 1.61μs | 0 | 0 | 0 | 44.32 KB |
| master | StringConcatBenchmark |
netcoreapp3.1 | 50.3μs | 292ns | 2.24μs | 0 | 0 | 0 | 42.71 KB |
| master | StringConcatBenchmark |
net472 | 57.8μs | 225ns | 809ns | 0 | 0 | 0 | 65.54 KB |
| master | StringConcatAspectBenchmark |
net6.0 | 473μs | 1.83μs | 6.33μs | 0 | 0 | 0 | 274.66 KB |
| master | StringConcatAspectBenchmark |
netcoreapp3.1 | 496μs | 1.45μs | 5.79μs | 0 | 0 | 0 | 255.29 KB |
| master | StringConcatAspectBenchmark |
net472 | 407μs | 2.18μs | 11.1μs | 0 | 0 | 0 | 286.72 KB |
| #7830 | StringConcatBenchmark |
net6.0 | 44.8μs | 204ns | 1.32μs | 0 | 0 | 0 | 43.89 KB |
| #7830 | StringConcatBenchmark |
netcoreapp3.1 | 48.7μs | 226ns | 814ns | 0 | 0 | 0 | 42.7 KB |
| #7830 | StringConcatBenchmark |
net472 | 56.9μs | 277ns | 1.36μs | 0 | 0 | 0 | 57.34 KB |
| #7830 | StringConcatAspectBenchmark |
net6.0 | 470μs | 1.32μs | 4.76μs | 0 | 0 | 0 | 274.46 KB |
| #7830 | StringConcatAspectBenchmark |
netcoreapp3.1 | 497μs | 776ns | 2.69μs | 0 | 0 | 0 | 257.68 KB |
| #7830 | StringConcatAspectBenchmark |
net472 | 406μs | 2.26μs | 15.4μ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.69μs | 13.9ns | 66.5ns | 0 | 0 | 0 | 1.7 KB |
| master | EnrichedLog |
netcoreapp3.1 | 3.67μs | 17.4ns | 69.5ns | 0 | 0 | 0 | 1.7 KB |
| master | EnrichedLog |
net472 | 3.8μs | 1.87ns | 6.99ns | 0.247 | 0 | 0 | 1.64 KB |
| #7830 | EnrichedLog |
net6.0 | 2.62μs | 13.9ns | 66.8ns | 0 | 0 | 0 | 1.7 KB |
| #7830 | EnrichedLog |
netcoreapp3.1 | 3.76μs | 18.5ns | 80.6ns | 0 | 0 | 0 | 1.7 KB |
| #7830 | EnrichedLog |
net472 | 3.86μs | 3.59ns | 13.9ns | 0.251 | 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 | 123μs | 109ns | 391ns | 0 | 0 | 0 | 4.31 KB |
| master | EnrichedLog |
netcoreapp3.1 | 128μs | 181ns | 702ns | 0 | 0 | 0 | 4.31 KB |
| master | EnrichedLog |
net472 | 168μs | 117ns | 453ns | 0 | 0 | 0 | 4.52 KB |
| #7830 | EnrichedLog |
net6.0 | 124μs | 475ns | 2.07μs | 0 | 0 | 0 | 4.31 KB |
| #7830 | EnrichedLog |
netcoreapp3.1 | 128μs | 422ns | 1.46μs | 0 | 0 | 0 | 4.31 KB |
| #7830 | EnrichedLog |
net472 | 169μs | 766ns | 2.76μs | 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 | 4.88μs | 23.6ns | 100ns | 0 | 0 | 0 | 2.26 KB |
| master | EnrichedLog |
netcoreapp3.1 | 6.68μs | 27.6ns | 107ns | 0 | 0 | 0 | 2.26 KB |
| master | EnrichedLog |
net472 | 7.45μs | 7.16ns | 27.7ns | 0.297 | 0 | 0 | 2.08 KB |
| #7830 | EnrichedLog |
net6.0 | 4.93μs | 14.7ns | 56.9ns | 0 | 0 | 0 | 2.26 KB |
| #7830 | EnrichedLog |
netcoreapp3.1 | 6.82μs | 16.4ns | 63.4ns | 0 | 0 | 0 | 2.26 KB |
| #7830 | EnrichedLog |
net472 | 7.48μs | 7.01ns | 27.1ns | 0.298 | 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.9μs | 9.24ns | 38.1ns | 0 | 0 | 0 | 1.2 KB |
| master | SendReceive |
netcoreapp3.1 | 2.56μs | 13.1ns | 58.6ns | 0 | 0 | 0 | 1.2 KB |
| master | SendReceive |
net472 | 3μs | 5.24ns | 20.3ns | 0.182 | 0 | 0 | 1.2 KB |
| #7830 | SendReceive |
net6.0 | 2μs | 10.3ns | 47.2ns | 0 | 0 | 0 | 1.2 KB |
| #7830 | SendReceive |
netcoreapp3.1 | 2.66μs | 13.7ns | 61.3ns | 0 | 0 | 0 | 1.2 KB |
| #7830 | SendReceive |
net472 | 3.01μs | 5.05ns | 19.6ns | 0.179 | 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.31μs | 4.08ns | 15.8ns | 0 | 0 | 0 | 1.58 KB |
| master | EnrichedLog |
netcoreapp3.1 | 5.63μs | 4.76ns | 18.4ns | 0 | 0 | 0 | 1.63 KB |
| master | EnrichedLog |
net472 | 6.73μs | 6.18ns | 23.9ns | 0.303 | 0 | 0 | 2.03 KB |
| #7830 | EnrichedLog |
net6.0 | 4.28μs | 16.2ns | 60.6ns | 0 | 0 | 0 | 1.58 KB |
| #7830 | EnrichedLog |
netcoreapp3.1 | 5.48μs | 10.4ns | 40.3ns | 0 | 0 | 0 | 1.63 KB |
| #7830 | EnrichedLog |
net472 | 6.67μs | 8.81ns | 34.1ns | 0.299 | 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 | 790ns | 3.67ns | 14.2ns | 0 | 0 | 0 | 576 B |
| master | StartFinishSpan |
netcoreapp3.1 | 959ns | 5.12ns | 26.1ns | 0 | 0 | 0 | 576 B |
| master | StartFinishSpan |
net472 | 963ns | 0.124ns | 0.428ns | 0.0917 | 0 | 0 | 578 B |
| master | StartFinishScope |
net6.0 | 919ns | 4.52ns | 19.7ns | 0 | 0 | 0 | 696 B |
| master | StartFinishScope |
netcoreapp3.1 | 1.2μs | 6.17ns | 31.4ns | 0 | 0 | 0 | 696 B |
| master | StartFinishScope |
net472 | 1.16μs | 0.194ns | 0.701ns | 0.0989 | 0 | 0 | 658 B |
| #7830 | StartFinishSpan |
net6.0 | 778ns | 4ns | 18.3ns | 0 | 0 | 0 | 576 B |
| #7830 | StartFinishSpan |
netcoreapp3.1 | 941ns | 4.97ns | 23.3ns | 0 | 0 | 0 | 576 B |
| #7830 | StartFinishSpan |
net472 | 969ns | 0.254ns | 0.982ns | 0.0877 | 0 | 0 | 578 B |
| #7830 | StartFinishScope |
net6.0 | 918ns | 4.35ns | 16.9ns | 0 | 0 | 0 | 696 B |
| #7830 | StartFinishScope |
netcoreapp3.1 | 1.19μs | 6.33ns | 31.6ns | 0 | 0 | 0 | 696 B |
| #7830 | StartFinishScope |
net472 | 1.15μs | 0.345ns | 1.34ns | 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 | 1.06μs | 5.46ns | 25ns | 0 | 0 | 0 | 696 B |
| master | RunOnMethodBegin |
netcoreapp3.1 | 1.48μs | 6.82ns | 26.4ns | 0 | 0 | 0 | 696 B |
| master | RunOnMethodBegin |
net472 | 1.44μs | 0.878ns | 3.4ns | 0.101 | 0 | 0 | 658 B |
| #7830 | RunOnMethodBegin |
net6.0 | 1.06μs | 5.1ns | 20.4ns | 0 | 0 | 0 | 696 B |
| #7830 | RunOnMethodBegin |
netcoreapp3.1 | 1.44μs | 7.17ns | 32.1ns | 0 | 0 | 0 | 696 B |
| #7830 | RunOnMethodBegin |
net472 | 1.47μs | 1.29ns | 4.98ns | 0.103 | 0 | 0 | 658 B |
tracer/src/Datadog.Trace/RuntimeMetrics/RuntimeMetricsWriter.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: NachoEchevarria <53266532+NachoEchevarria@users.noreply.github.com>
tracer/src/Datadog.Trace/RuntimeMetrics/RuntimeMetricsWriter.cs
Outdated
Show resolved
Hide resolved
NachoEchevarria
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks!
Co-authored-by: NachoEchevarria <53266532+NachoEchevarria@users.noreply.github.com>
Summary of changes
Avoid having the callback from a
Timerreconfigure itselfReason for change
We have seem some instances of StackOverflowExceptions that point the finger at the
RuntimeMetricsWriterand the way it handlesPushEvents:Today, the
RuntimeMetricsWritercreates a timer that doesn't repeat, and firesPushEvents()after the delay. Inside thePushEvents()method, after grabbing the metrics, it calculates the required delay (accounting for drift) and reconfigures the timer. This ensures we don't have concurrent collections, and we avoid drift as much as possible.However, as best as we can tell, if the calculated delay required is very small, it looks like this can handle the callback on the same thread, and we could end up in a recursive situation:
Implementation details
To avoid the possibility of recursion (and all the weirdness that comes with timers), we switch away from the
Timerapproach, and instead use a long-running task (i.e. dedicated thread) and justThread.Sleepfor the delay. This is suboptimal because:Thread.Sleep(), so we have to sleep for small periods, check if we're disposed and wake up. This will likely cause a small amount of drift (the time to wake up and execute the loop logic). We could account for this by setting a "deadline" forDateTime.UtcNowinstead of the "duration requirement". Both have pros and cons.We could switch to making things async instead, and use the
ThreadPoolbut it's not clear whether all the kernel calls are a bit time consuming for a threadpool thread 🤷♂️Finally, we've only seen this issue in .NET Framework, so to try to minimize the blast radius, this PR limits the change to .NET Framework.
Test coverage
Should be covered by existing, as it's an internal refactoring