-
Notifications
You must be signed in to change notification settings - Fork 144
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
[IAST] Fix flaky Interpolated Strings tests #6555
Conversation
Datadog ReportBranch report: ✅ 0 Failed, 242184 Passed, 2001 Skipped, 19h 16m 48.56s Total Time |
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing the following branches/commits: Execution-time benchmarks measure the whole time it takes to execute a program. And are intended to measure the one-off costs. Cases where the execution time results for the PR are worse than latest master results are shown in red. The following thresholds were used for comparing the execution times:
Note that these results are based on a single point-in-time result for each branch. For full results, see the dashboard. Graphs show the p99 interval based on the mean and StdDev of the test run, as well as the mean value of the run (shown as a diamond below the graph). gantt
title Execution time (ms) FakeDbCommand (.NET Framework 4.6.2)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6555) - mean (69ms) : 66, 72
. : milestone, 69,
master - mean (69ms) : 65, 74
. : milestone, 69,
section CallTarget+Inlining+NGEN
This PR (6555) - mean (982ms) : 954, 1010
. : milestone, 982,
master - mean (981ms) : 959, 1003
. : milestone, 981,
gantt
title Execution time (ms) FakeDbCommand (.NET Core 3.1)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6555) - mean (108ms) : 105, 110
. : milestone, 108,
master - mean (108ms) : 106, 111
. : milestone, 108,
section CallTarget+Inlining+NGEN
This PR (6555) - mean (677ms) : 661, 693
. : milestone, 677,
master - mean (676ms) : 660, 691
. : milestone, 676,
gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6555) - mean (91ms) : 89, 94
. : milestone, 91,
master - mean (91ms) : 89, 93
. : milestone, 91,
section CallTarget+Inlining+NGEN
This PR (6555) - mean (630ms) : 611, 648
. : milestone, 630,
master - mean (637ms) : 614, 660
. : milestone, 637,
gantt
title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6555) - mean (190ms) : 185, 195
. : milestone, 190,
master - mean (190ms) : 185, 195
. : milestone, 190,
section CallTarget+Inlining+NGEN
This PR (6555) - mean (1,087ms) : 1065, 1110
. : milestone, 1087,
master - mean (1,087ms) : 1064, 1110
. : milestone, 1087,
gantt
title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6555) - mean (276ms) : 272, 280
. : milestone, 276,
master - mean (276ms) : 272, 281
. : milestone, 276,
section CallTarget+Inlining+NGEN
This PR (6555) - mean (866ms) : 835, 896
. : milestone, 866,
master - mean (865ms) : 832, 897
. : milestone, 865,
gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6555) - mean (264ms) : 260, 269
. : milestone, 264,
master - mean (264ms) : 260, 268
. : milestone, 264,
section CallTarget+Inlining+NGEN
This PR (6555) - mean (844ms) : 807, 881
. : milestone, 844,
master - mean (846ms) : 807, 885
. : milestone, 846,
|
Benchmarks Report for tracer 🐌Benchmarks for #6555 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 ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.DbCommandBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.ElasticsearchBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.ILoggerBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.Log4netBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.NLogBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.RedisBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.SerilogBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.SpanBenchmark - Slower
|
Benchmark | diff/base | Base Median (ns) | Diff Median (ns) | Modality |
---|---|---|---|---|
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net6.0 | 1.145 | 393.90 | 451.08 | |
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑netcoreapp3.1 | 1.144 | 547.93 | 626.62 |
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | StartFinishSpan |
net6.0 | 394ns | 0.68ns | 2.63ns | 0.00797 | 0 | 0 | 576 B |
master | StartFinishSpan |
netcoreapp3.1 | 549ns | 0.822ns | 3.18ns | 0.00775 | 0 | 0 | 576 B |
master | StartFinishSpan |
net472 | 633ns | 1.31ns | 5.09ns | 0.0915 | 0 | 0 | 578 B |
master | StartFinishScope |
net6.0 | 487ns | 1.12ns | 4.35ns | 0.00976 | 0 | 0 | 696 B |
master | StartFinishScope |
netcoreapp3.1 | 698ns | 1.82ns | 6.8ns | 0.00952 | 0 | 0 | 696 B |
master | StartFinishScope |
net472 | 827ns | 1.31ns | 5.08ns | 0.104 | 0 | 0 | 658 B |
#6555 | StartFinishSpan |
net6.0 | 451ns | 0.397ns | 1.54ns | 0.00806 | 0 | 0 | 576 B |
#6555 | StartFinishSpan |
netcoreapp3.1 | 626ns | 0.953ns | 3.57ns | 0.0076 | 0 | 0 | 576 B |
#6555 | StartFinishSpan |
net472 | 628ns | 1.05ns | 4.07ns | 0.0918 | 0 | 0 | 578 B |
#6555 | StartFinishScope |
net6.0 | 474ns | 0.518ns | 2.01ns | 0.00979 | 0 | 0 | 696 B |
#6555 | StartFinishScope |
netcoreapp3.1 | 678ns | 0.937ns | 3.51ns | 0.00953 | 0 | 0 | 696 B |
#6555 | StartFinishScope |
net472 | 869ns | 1.45ns | 5.62ns | 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 | 694ns | 0.825ns | 3.2ns | 0.00981 | 0 | 0 | 696 B |
master | RunOnMethodBegin |
netcoreapp3.1 | 903ns | 1.37ns | 5.29ns | 0.00918 | 0 | 0 | 696 B |
master | RunOnMethodBegin |
net472 | 1.04μs | 1.37ns | 5.3ns | 0.104 | 0 | 0 | 658 B |
#6555 | RunOnMethodBegin |
net6.0 | 626ns | 0.949ns | 3.55ns | 0.00962 | 0 | 0 | 696 B |
#6555 | RunOnMethodBegin |
netcoreapp3.1 | 913ns | 0.9ns | 3.49ns | 0.00902 | 0 | 0 | 696 B |
#6555 | RunOnMethodBegin |
net472 | 1.09μs | 2.54ns | 9.83ns | 0.104 | 0 | 0 | 658 B |
3d2ad73
to
126c73b
Compare
Datadog ReportBranch report: ✅ 0 Failed, 243786 Passed, 2076 Skipped, 19h 34m 48.68s Total Time |
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.
Finally a fix for this one 😄 Thanks!
tracer/src/Datadog.Trace/Iast/Propagation/DefaultInterpolatedStringHandlerModuleImpl.cs
Outdated
Show resolved
Hide resolved
tracer/src/Datadog.Trace/Iast/Propagation/DefaultInterpolatedStringHandlerModuleImpl.cs
Outdated
Show resolved
Hide resolved
Benchmarks Report for appsec 🐌Benchmarks for #6555 compared to master:
The following thresholds were used for comparing the benchmark speeds:
Allocation changes below 0.5% are ignored. Benchmark detailsBenchmarks.Trace.Asm.AppSecBodyBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.Asm.AppSecEncoderBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.Asm.AppSecWafBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.Iast.StringAspectsBenchmark - Same speed ✔️ More allocations
|
Benchmark | Base Allocated | Diff Allocated | Change | Change % |
---|---|---|---|---|
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0 | 254.7 KB | 266.09 KB | 11.38 KB | 4.47% |
Benchmark | Base Allocated | Diff Allocated | Change | Change % |
---|---|---|---|---|
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑netcoreapp3.1 | 262.55 KB | 252.89 KB | -9.66 KB | -3.68% |
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net472 | 61.9 KB | 59.43 KB | -2.47 KB | -3.99% |
Raw results
Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|---|
master | StringConcatBenchmark |
net6.0 | 52.9μs | 248ns | 1.24μs | 0 | 0 | 0 | 43.44 KB |
master | StringConcatBenchmark |
netcoreapp3.1 | 59.5μs | 754ns | 7.31μs | 0 | 0 | 0 | 42.64 KB |
master | StringConcatBenchmark |
net472 | 37.4μs | 152ns | 527ns | 0 | 0 | 0 | 61.9 KB |
master | StringConcatAspectBenchmark |
net6.0 | 302μs | 5.51μs | 54.8μs | 0 | 0 | 0 | 254.7 KB |
master | StringConcatAspectBenchmark |
netcoreapp3.1 | 348μs | 1.95μs | 12.3μs | 0 | 0 | 0 | 262.55 KB |
master | StringConcatAspectBenchmark |
net472 | 293μs | 5.78μs | 56.6μs | 0 | 0 | 0 | 278.53 KB |
#6555 | StringConcatBenchmark |
net6.0 | 60.2μs | 740ns | 7.32μs | 0 | 0 | 0 | 43.44 KB |
#6555 | StringConcatBenchmark |
netcoreapp3.1 | 54.4μs | 269ns | 1.07μs | 0 | 0 | 0 | 42.64 KB |
#6555 | StringConcatBenchmark |
net472 | 37.8μs | 166ns | 620ns | 0 | 0 | 0 | 59.43 KB |
#6555 | StringConcatAspectBenchmark |
net6.0 | 315μs | 1.7μs | 10.5μs | 0 | 0 | 0 | 266.09 KB |
#6555 | StringConcatAspectBenchmark |
netcoreapp3.1 | 317μs | 5.07μs | 50μs | 0 | 0 | 0 | 252.89 KB |
#6555 | StringConcatAspectBenchmark |
net472 | 295μs | 6.55μs | 64.5μs | 0 | 0 | 0 | 278.53 KB |
Snapshots difference summaryThe following differences have been observed in committed snapshots. It is meant to help the reviewer. 1 occurrences of : - "value": "'3','32.38','Vins et alcools Chevalier','John',",
+ "value": "'3','32','Vins et alcools Chevalier','John',",
[...]
- "value": "'Reims','51100','France')",
- "source": 0
- },
- {
- "value": ";\nSELECT OrderID FROM Orders ORDER BY OrderID DESC LIMIT 1;"
+ "value": "'Reims','51100','France');\nSELECT OrderID FROM Orders ORDER BY OrderID DESC LIMIT 1;"
|
tracer/src/Datadog.Trace/Iast/Propagation/DefaultInterpolatedStringHandlerModuleImpl.cs
Outdated
Show resolved
Hide resolved
tracer/src/Datadog.Trace/Iast/Propagation/DefaultInterpolatedStringHandlerModuleImpl.cs
Outdated
Show resolved
Hide resolved
439ee01
to
b28b996
Compare
Summary of changes
Fix test flakiness by keeping alive the tainted boxed object during the lifespan of the ref struct
Reason for change
If a GC collect happened between the tainting of the
DefaultInterpolatedStringHandler
and the call toToString
the boxed object was collected and the weak reference was lost, causing the loss of the tainted status.Thanks to @e-n-0 for finding what was happening
IDK who said flakiness was bad
Implementation details
Added a thread local queue to hold the boxed object of the tainted ref structs
Test coverage
Added a unit test
Other details