Skip to content
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

[Dynamic Instrumentation] Improved instrumentation matching of symbols received through SymDb #5829

Merged
merged 2 commits into from
Aug 5, 2024

Conversation

GreenMatan
Copy link
Contributor

@GreenMatan GreenMatan commented Jul 30, 2024

Summary of changes

We are on the edge of advancing SymDb to Open Beta. We found a few issues that blocked us in doing so:

  • Generic types, methods and arguments received surrounded with < and > while the native matcher is based on [ and ].
  • The parser of the signature in the managed side of the debugger implemented naively, mainly splitted by ,. Generic params are comma separated too, which failed to parse it correctly.
  • Static methods were not handled correctly in the native side. It naively skipped the first param, as if all the methods it deals with are instance methods.
  • The signature received by SymDb is surrounded by ( and ) and has space in between every param type.

Reason for change

SymDb readiness for Open Beta.

Implementation details

  • In the managed side, upon receiving a request to instrument a method with a signature that is targeting a generic method/type, the < and > characters are replaced with [ and ] respectively.
  • Parsing the signature in a more robust way that handles the generic case where comma could present in between every generic param.
  • Static methods are now correctly handled in the native side when a request arrives with a signature exact matching.
  • Correctly parsing the signature when it comes surrounded by ( and ), including space in between every param type.

Test coverage

@GreenMatan GreenMatan changed the title [SymDb] Fixed issues where we failed to instrument methods received by SymDb [SymDb] Fixed instrumentation matchmaking failure with symbols received through SymDb Jul 30, 2024
@GreenMatan GreenMatan changed the title [SymDb] Fixed instrumentation matchmaking failure with symbols received through SymDb [SymDb] Fixed instrumentation matching failure with symbols received through SymDb Jul 30, 2024
@GreenMatan GreenMatan marked this pull request as ready for review July 30, 2024 20:04
@GreenMatan GreenMatan requested review from a team as code owners July 30, 2024 20:04
@GreenMatan GreenMatan changed the title [SymDb] Fixed instrumentation matching failure with symbols received through SymDb [SymDb] Improved instrumentation matching of symbols received through SymDb Jul 30, 2024
@andrewlock
Copy link
Member

andrewlock commented Jul 30, 2024

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:

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

gantt
    title Execution time (ms) FakeDbCommand (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5829) - mean (72ms)  : 64, 81
     .   : milestone, 72,
    master - mean (74ms)  : 64, 83
     .   : milestone, 74,

    section CallTarget+Inlining+NGEN
    This PR (5829) - mean (1,060ms)  : 1041, 1080
     .   : milestone, 1060,
    master - mean (1,069ms)  : 1047, 1091
     .   : milestone, 1069,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5829) - mean (108ms)  : 104, 112
     .   : milestone, 108,
    master - mean (109ms)  : 104, 113
     .   : milestone, 109,

    section CallTarget+Inlining+NGEN
    This PR (5829) - mean (749ms)  : 725, 773
     .   : milestone, 749,
    master - mean (747ms)  : 724, 771
     .   : milestone, 747,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5829) - mean (92ms)  : 88, 97
     .   : milestone, 92,
    master - mean (93ms)  : 87, 98
     .   : milestone, 93,

    section CallTarget+Inlining+NGEN
    This PR (5829) - mean (702ms)  : 685, 720
     .   : milestone, 702,
    master - mean (704ms)  : 686, 722
     .   : milestone, 704,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5829) - mean (192ms)  : 188, 197
     .   : milestone, 192,
    master - mean (192ms)  : 189, 196
     .   : milestone, 192,

    section CallTarget+Inlining+NGEN
    This PR (5829) - mean (1,168ms)  : 1140, 1197
     .   : milestone, 1168,
    master - mean (1,165ms)  : 1130, 1200
     .   : milestone, 1165,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5829) - mean (278ms)  : 274, 283
     .   : milestone, 278,
    master - mean (275ms)  : 271, 280
     .   : milestone, 275,

    section CallTarget+Inlining+NGEN
    This PR (5829) - mean (930ms)  : 892, 968
     .   : milestone, 930,
    master - mean (917ms)  : 894, 940
     .   : milestone, 917,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5829) - mean (267ms)  : 262, 272
     .   : milestone, 267,
    master - mean (266ms)  : 261, 270
     .   : milestone, 266,

    section CallTarget+Inlining+NGEN
    This PR (5829) - mean (903ms)  : 882, 925
     .   : milestone, 903,
    master - mean (916ms)  : 890, 942
     .   : milestone, 916,

Loading

@datadog-ddstaging
Copy link

datadog-ddstaging bot commented Jul 30, 2024

Datadog Report

Branch report: matang/symdb-fixes
Commit report: 1bd2d3a
Test service: dd-trace-dotnet

✅ 0 Failed, 348415 Passed, 2222 Skipped, 23h 3m 27.71s Total Time

@andrewlock
Copy link
Member

andrewlock commented Jul 30, 2024

Throughput/Crank Report ⚡

Throughput results for AspNetCoreSimpleController comparing the following branches/commits:

Cases where throughput results for the PR are worse than latest master (5% drop or greater), results are shown in red.

Note that these results are based on a single point-in-time result for each branch. For full results, see one of the many, many dashboards!

gantt
    title Throughput Linux x64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (5829) (11.544M)   : 0, 11544045
    master (11.678M)   : 0, 11677880
    benchmarks/2.9.0 (11.335M)   : 0, 11335046

    section Automatic
    This PR (5829) (7.665M)   : 0, 7664621
    master (7.838M)   : 0, 7838430
    benchmarks/2.9.0 (8.124M)   : 0, 8123605

    section Trace stats
    master (8.299M)   : 0, 8298729

    section Manual
    master (11.707M)   : 0, 11706878

    section Manual + Automatic
    This PR (5829) (7.267M)   : 0, 7267474
    master (7.279M)   : 0, 7279436

    section DD_TRACE_ENABLED=0
    master (10.797M)   : 0, 10797180

Loading
gantt
    title Throughput Linux arm64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (5829) (9.496M)   : 0, 9496159
    master (9.804M)   : 0, 9804149

    section Automatic
    This PR (5829) (6.516M)   : 0, 6515891
    master (6.472M)   : 0, 6471648

    section Trace stats
    master (6.970M)   : 0, 6969517

    section Manual
    master (9.638M)   : 0, 9637761

    section Manual + Automatic
    This PR (5829) (6.168M)   : 0, 6168482
    master (6.084M)   : 0, 6083512

    section DD_TRACE_ENABLED=0
    master (9.140M)   : 0, 9139891

Loading
gantt
    title Throughput Windows x64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (5829) (9.966M)   : 0, 9965927
    benchmarks/2.9.0 (10.092M)   : 0, 10091577

    section Automatic
    This PR (5829) (6.796M)   : 0, 6796292
    benchmarks/2.9.0 (7.470M)   : 0, 7469858

    section Manual + Automatic
    This PR (5829) (6.362M)   : 0, 6361909

Loading

@GreenMatan GreenMatan force-pushed the matang/symdb-fixes branch 2 times, most recently from 788cc9a to c23faf1 Compare July 30, 2024 23:34
@andrewlock
Copy link
Member

andrewlock commented Jul 31, 2024

Benchmarks Report for tracer 🐌

Benchmarks for #5829 compared to master:

  • 2 benchmarks are slower, with geometric mean 1.133
  • All benchmarks have the same 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 ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartStopWithChild net6.0 7.47μs 37.2ns 197ns 0.0156 0.0078 0 5.43 KB
master StartStopWithChild netcoreapp3.1 9.96μs 53ns 290ns 0.0201 0.01 0 5.62 KB
master StartStopWithChild net472 16.1μs 59ns 228ns 1.03 0.329 0.0962 6.07 KB
#5829 StartStopWithChild net6.0 7.52μs 31.9ns 119ns 0.0153 0.00763 0 5.42 KB
#5829 StartStopWithChild netcoreapp3.1 9.8μs 54.3ns 343ns 0.0192 0.00962 0 5.62 KB
#5829 StartStopWithChild net472 16.1μs 61.1ns 236ns 1.04 0.336 0.0938 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 458μs 218ns 814ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 658μs 599ns 2.32μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 852μs 614ns 2.38μs 0.425 0 0 3.3 KB
#5829 WriteAndFlushEnrichedTraces net6.0 464μs 333ns 1.29μs 0 0 0 2.7 KB
#5829 WriteAndFlushEnrichedTraces netcoreapp3.1 633μs 459ns 1.72μs 0 0 0 2.7 KB
#5829 WriteAndFlushEnrichedTraces net472 857μs 411ns 1.59μs 0.425 0 0 3.3 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 195μs 1.11μs 7.98μs 0.191 0 0 18.45 KB
master SendRequest netcoreapp3.1 216μs 1.23μs 9.06μs 0.217 0 0 20.61 KB
master SendRequest net472 0.000293ns 0.0002ns 0.000748ns 0 0 0 0 b
#5829 SendRequest net6.0 197μs 1.06μs 6.76μs 0.191 0 0 18.45 KB
#5829 SendRequest netcoreapp3.1 218μs 1.19μs 6.92μs 0.226 0 0 20.61 KB
#5829 SendRequest net472 0.000171ns 0.000171ns 0.000661ns 0 0 0 0 b
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 591μs 3.29μs 20μs 0.548 0 0 41.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 697μs 3.98μs 29μs 0.347 0 0 41.77 KB
master WriteAndFlushEnrichedTraces net472 854μs 3.24μs 12.1μs 8.19 2.59 0.431 53.3 KB
#5829 WriteAndFlushEnrichedTraces net6.0 589μs 5.26μs 49.4μs 0.347 0 0 41.56 KB
#5829 WriteAndFlushEnrichedTraces netcoreapp3.1 693μs 3.75μs 21.2μs 0.345 0 0 41.83 KB
#5829 WriteAndFlushEnrichedTraces net472 872μs 4.26μs 18.6μs 8.5 2.55 0.425 53.28 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.19μs 0.516ns 2ns 0.0144 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.71μs 1.28ns 4.95ns 0.0137 0 0 1.02 KB
master ExecuteNonQuery net472 2.05μs 1.57ns 6.07ns 0.157 0 0 987 B
#5829 ExecuteNonQuery net6.0 1.25μs 1.38ns 5.35ns 0.0143 0 0 1.02 KB
#5829 ExecuteNonQuery netcoreapp3.1 1.66μs 1.93ns 6.96ns 0.0134 0 0 1.02 KB
#5829 ExecuteNonQuery net472 2μs 2.48ns 9.61ns 0.157 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.21μs 2.65ns 10.3ns 0.0137 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.51μs 1.38ns 5.16ns 0.013 0 0 976 B
master CallElasticsearch net472 2.54μs 1.07ns 4.16ns 0.157 0 0 995 B
master CallElasticsearchAsync net6.0 1.18μs 0.791ns 3.06ns 0.0132 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.63μs 0.848ns 3.06ns 0.014 0 0 1.02 KB
master CallElasticsearchAsync net472 2.68μs 1.78ns 6.67ns 0.167 0 0 1.05 KB
#5829 CallElasticsearch net6.0 1.18μs 0.82ns 3.18ns 0.0137 0 0 976 B
#5829 CallElasticsearch netcoreapp3.1 1.48μs 1.22ns 4.57ns 0.0132 0 0 976 B
#5829 CallElasticsearch net472 2.48μs 0.762ns 2.75ns 0.157 0 0 995 B
#5829 CallElasticsearchAsync net6.0 1.3μs 0.903ns 3.38ns 0.0135 0 0 952 B
#5829 CallElasticsearchAsync netcoreapp3.1 1.61μs 1.09ns 4.22ns 0.0137 0 0 1.02 KB
#5829 CallElasticsearchAsync net472 2.69μs 2.28ns 8.55ns 0.167 0 0 1.05 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.31μs 1.56ns 5.84ns 0.0131 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.67μs 1ns 3.74ns 0.0124 0 0 952 B
master ExecuteAsync net472 1.69μs 1.1ns 4.28ns 0.145 0 0 915 B
#5829 ExecuteAsync net6.0 1.3μs 0.593ns 2.22ns 0.013 0 0 952 B
#5829 ExecuteAsync netcoreapp3.1 1.67μs 0.901ns 3.49ns 0.0126 0 0 952 B
#5829 ExecuteAsync net472 1.69μs 0.803ns 3.11ns 0.145 0.000852 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 4.28μs 1.61ns 5.81ns 0.0301 0 0 2.22 KB
master SendAsync netcoreapp3.1 5.14μs 5.12ns 19.2ns 0.036 0 0 2.76 KB
master SendAsync net472 7.66μs 10.5ns 39.3ns 0.498 0 0 3.15 KB
#5829 SendAsync net6.0 4.14μs 1.35ns 4.88ns 0.0308 0 0 2.22 KB
#5829 SendAsync netcoreapp3.1 5μs 1.04ns 4.02ns 0.0379 0 0 2.76 KB
#5829 SendAsync net472 7.73μs 2.91ns 11.3ns 0.498 0 0 3.15 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 1.47μs 1.12ns 4.35ns 0.0228 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.23μs 1.8ns 6.72ns 0.0222 0 0 1.64 KB
master EnrichedLog net472 2.77μs 0.946ns 3.66ns 0.249 0 0 1.57 KB
#5829 EnrichedLog net6.0 1.52μs 1.88ns 7.04ns 0.0228 0 0 1.64 KB
#5829 EnrichedLog netcoreapp3.1 2.16μs 0.811ns 3.03ns 0.0215 0 0 1.64 KB
#5829 EnrichedLog net472 2.51μs 1.44ns 5.4ns 0.249 0 0 1.57 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 117μs 169ns 655ns 0 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 119μs 187ns 725ns 0 0 0 4.28 KB
master EnrichedLog net472 147μs 315ns 1.22μs 0.66 0.22 0 4.46 KB
#5829 EnrichedLog net6.0 116μs 336ns 1.3μs 0.0568 0 0 4.28 KB
#5829 EnrichedLog netcoreapp3.1 119μs 261ns 1.01μs 0 0 0 4.28 KB
#5829 EnrichedLog net472 148μs 229ns 887ns 0.672 0.224 0 4.46 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 3.09μs 1.26ns 4.72ns 0.0308 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.32μs 3.39ns 13.1ns 0.0282 0 0 2.2 KB
master EnrichedLog net472 4.83μs 3.33ns 12.9ns 0.32 0 0 2.02 KB
#5829 EnrichedLog net6.0 3.13μs 0.848ns 3.17ns 0.0311 0 0 2.2 KB
#5829 EnrichedLog netcoreapp3.1 4.06μs 2.08ns 7.77ns 0.0284 0 0 2.2 KB
#5829 EnrichedLog net472 4.87μs 0.828ns 3.21ns 0.318 0 0 2.02 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.42μs 0.784ns 2.83ns 0.0163 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.83μs 2.27ns 8.17ns 0.0155 0 0 1.14 KB
master SendReceive net472 2.05μs 3.21ns 11.6ns 0.184 0 0 1.16 KB
#5829 SendReceive net6.0 1.29μs 0.673ns 2.61ns 0.0158 0 0 1.14 KB
#5829 SendReceive netcoreapp3.1 1.75μs 1.77ns 6.61ns 0.0157 0 0 1.14 KB
#5829 SendReceive net472 2.11μs 1.21ns 4.7ns 0.183 0.00106 0 1.16 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 2.69μs 1.01ns 3.9ns 0.023 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 3.91μs 1.12ns 4.34ns 0.0215 0 0 1.65 KB
master EnrichedLog net472 4.51μs 2.96ns 11.1ns 0.322 0 0 2.04 KB
#5829 EnrichedLog net6.0 2.81μs 0.489ns 1.76ns 0.0225 0 0 1.6 KB
#5829 EnrichedLog netcoreapp3.1 3.94μs 1.61ns 6.25ns 0.0216 0 0 1.65 KB
#5829 EnrichedLog net472 4.36μs 1.6ns 6.19ns 0.324 0 0 2.04 KB
Benchmarks.Trace.SpanBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #5829

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net6.0 1.140 396.94 452.46
Benchmarks.Trace.SpanBenchmark.StartFinishScope‑net6.0 1.127 478.25 539.06

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 396ns 0.64ns 2.48ns 0.00809 0 0 576 B
master StartFinishSpan netcoreapp3.1 558ns 0.246ns 0.92ns 0.00781 0 0 576 B
master StartFinishSpan net472 676ns 1.02ns 3.94ns 0.0918 0 0 578 B
master StartFinishScope net6.0 478ns 0.106ns 0.398ns 0.00983 0 0 696 B
master StartFinishScope netcoreapp3.1 754ns 0.343ns 1.28ns 0.00945 0 0 696 B
master StartFinishScope net472 835ns 0.552ns 2.07ns 0.104 0 0 658 B
#5829 StartFinishSpan net6.0 453ns 1.3ns 4.85ns 0.0081 0 0 576 B
#5829 StartFinishSpan netcoreapp3.1 598ns 0.214ns 0.802ns 0.00751 0 0 576 B
#5829 StartFinishSpan net472 634ns 0.722ns 2.8ns 0.0915 0 0 578 B
#5829 StartFinishScope net6.0 539ns 0.146ns 0.564ns 0.00969 0 0 696 B
#5829 StartFinishScope netcoreapp3.1 782ns 0.256ns 0.99ns 0.00962 0 0 696 B
#5829 StartFinishScope net472 844ns 0.475ns 1.84ns 0.105 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 609ns 0.258ns 0.998ns 0.00975 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 896ns 0.455ns 1.76ns 0.00925 0 0 696 B
master RunOnMethodBegin net472 1.14μs 0.432ns 1.67ns 0.105 0 0 658 B
#5829 RunOnMethodBegin net6.0 654ns 0.285ns 1.1ns 0.00956 0 0 696 B
#5829 RunOnMethodBegin netcoreapp3.1 917ns 1.47ns 5.69ns 0.00934 0 0 696 B
#5829 RunOnMethodBegin net472 1.09μs 0.393ns 1.52ns 0.105 0 0 658 B

@GreenMatan GreenMatan force-pushed the matang/symdb-fixes branch 2 times, most recently from f070651 to e7cb939 Compare July 31, 2024 09:55
@GreenMatan GreenMatan changed the title [SymDb] Improved instrumentation matching of symbols received through SymDb [Dynamic Instrumentation] Improved instrumentation matching of symbols received through SymDb Jul 31, 2024
Copy link
Contributor

@dudikeleti dudikeleti left a comment

Choose a reason for hiding this comment

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

LGTM
left a few comments.

tracer/src/Datadog.Trace/Debugger/LiveDebugger.cs Outdated Show resolved Hide resolved
}
else
{
if (c == '<')
Copy link
Contributor

Choose a reason for hiding this comment

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

Sometimes the type himself can contains < as part of his name, is that logic will break in this case?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, does this need to handle unpronounceable types generated by the compiler? e.g. <PrivateImplementationDetails> and <>z__ReadOnlyArray<T>? I'd love to see unit tests for these if nothing else, to confirm that we bail-out at worst case, rather than generating something weird.

Similarly, do we need to handle open-generics?

Copy link
Contributor Author

@GreenMatan GreenMatan Aug 4, 2024

Choose a reason for hiding this comment

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

Open generic is handled as closed generic. E.g Foo'1<Some.Class> -> Foo'1[Some.Class] and Foo'1<!0> -> Foo'1[!0].
Refactored around + added unit tests in 4f6c7be.

tracer/src/Datadog.Trace/Debugger/LiveDebugger.cs Outdated Show resolved Hide resolved
}

return types.ToArray();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have unit tests for that? IMO we must add some to verify the correctness because it's in a very critical path (adding probes).

Some suggestions:

  • P<T<V,K>> arg1, K<T<V>, P<K>>arg2
  • <c>_someGeneratedType arg1, anotherOne<>c arg2
  • Also worth checking arguments with attributes and default values

Copy link
Contributor Author

@GreenMatan GreenMatan Jul 31, 2024

Choose a reason for hiding this comment

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

For the more esoteric signatures we shall first assess what the SymDb is uploading. I'm currently adding unit tests for the signature parser, including generics.

Copy link
Contributor Author

@GreenMatan GreenMatan Aug 4, 2024

Choose a reason for hiding this comment

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

Added the unit tests in 4f6c7be.

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.

Only checked the managed side, but IMO the ParseSignature should have unit tests before merging.

tracer/src/Datadog.Trace/Debugger/LiveDebugger.cs Outdated Show resolved Hide resolved
tracer/src/Datadog.Trace/Debugger/LiveDebugger.cs Outdated Show resolved Hide resolved
tracer/src/Datadog.Trace/Debugger/LiveDebugger.cs Outdated Show resolved Hide resolved
}
else
{
if (c == '<')
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, does this need to handle unpronounceable types generated by the compiler? e.g. <PrivateImplementationDetails> and <>z__ReadOnlyArray<T>? I'd love to see unit tests for these if nothing else, to confirm that we bail-out at worst case, rather than generating something weird.

Similarly, do we need to handle open-generics?

tracer/src/Datadog.Trace/Debugger/LiveDebugger.cs Outdated Show resolved Hide resolved
tracer/src/Datadog.Trace/Debugger/LiveDebugger.cs Outdated Show resolved Hide resolved
tracer/src/Datadog.Trace/Debugger/LiveDebugger.cs Outdated Show resolved Hide resolved
@GreenMatan GreenMatan force-pushed the matang/symdb-fixes branch 9 times, most recently from dc427de to a1b787b Compare August 5, 2024 10:29
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 for adding the tests, that clears up my concerns! 🙂

tracer/src/Datadog.Trace/Debugger/SignatureParser.cs Outdated Show resolved Hide resolved
[InlineData("Class1<Class2<Class3<Class4>>>", new[] { "Class1[Class2[Class3[Class4]]]" })]
[InlineData("(Namespace1.Class1`1<Namespace2.Class2`1<Namespace3.Class3>)", null)]
[InlineData("Namespace1.Class1`1<Namespace2.<PrivateImplementationDetails>, Namespace3.Class3>", new[] { "Namespace1.Class1`1[Namespace2.[PrivateImplementationDetails],Namespace3.Class3]" })]
[InlineData("Namespace1.Class1`1<Namespace2.<>z__ReadOnlyArray<T>, Namespace3.Class3>", new[] { "Namespace1.Class1`1[Namespace2.<>z__ReadOnlyArray[T],Namespace3.Class3]" })]
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is actually a valid signature is it? 😅 Probably doesn't matter I guess (and maybe preferable in fact, as shows we're not dependent on parsing the `1

Copy link
Contributor Author

@GreenMatan GreenMatan Aug 5, 2024

Choose a reason for hiding this comment

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

Correct, it shall be `2 as there are two params. I don't parse out the amount of generics and verify that - not sure it's worth it. But in general you're right. If we'll improve the code to actually do that- those tests will fail 🤓

Copy link
Member

Choose a reason for hiding this comment

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

I agree, I don't know that it's worth it either, just wanted to verify. And if we do decide to do that, this will serve as proof it works😃

public class SignatureParserTests
{
[Theory]
[InlineData("(P<T<V,K>>, K<T<V>, P<K>>)", new[] { "P[T[V,K]]", "K[T[V],P[K]]" })]
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for adding all these 😍

@GreenMatan GreenMatan merged commit d00bcab into master Aug 5, 2024
71 of 74 checks passed
@GreenMatan GreenMatan deleted the matang/symdb-fixes branch August 5, 2024 13:56
@github-actions github-actions bot added this to the vNext-v3 milestone Aug 5, 2024
GreenMatan added a commit that referenced this pull request Aug 5, 2024
…s received through SymDb (#5829)

## Summary of changes
We are on the edge of advancing SymDb to Open Beta. We found a few
issues that blocked us in doing so:
- Generic types, methods and arguments received surrounded with `<` and
`>` while the native matcher is based on `[` and `]`.
- The parser of the signature in the managed side of the debugger
implemented naively, mainly splitted by `,`. Generic params are comma
separated too, which failed to parse it correctly.
- Static methods were not handled correctly in the native side. It
naively skipped the first param, as if all the methods it deals with are
instance methods.
- The signature received by SymDb is surrounded by `(` and `)` and has
space in between every param type.

## Reason for change
SymDb readiness for Open Beta.

## Implementation details
- In the managed side, upon receiving a request to instrument a method
with a signature that is targeting a generic method/type, the `<` and
`>` characters are replaced with `[` and `]` respectively.
- Parsing the signature in a more robust way that handles the generic
case where comma could present in between every generic param.
- Static methods are now correctly handled in the native side when a
request arrives with a signature exact matching.
- Correctly parsing the signature when it comes surrounded by `(` and
`)`, including space in between every param type.

## Test coverage
-
[SignatureParserTests](https://github.com/DataDog/dd-trace-dotnet/blob/a8a2df542625b29e3f0d2ce8c745717f27abdb0a/tracer/test/Datadog.Trace.Debugger.IntegrationTests/SignatureParserTests.cs)
GreenMatan added a commit that referenced this pull request Aug 5, 2024
…s received through SymDb (#5829 -> v2) (#5847)

## Summary of changes
We are on the edge of advancing SymDb to Open Beta. We found a few
issues that blocked us in doing so:
- Generic types, methods and arguments received surrounded with `<` and
`>` while the native matcher is based on `[` and `]`.
- The parser of the signature in the managed side of the debugger
implemented naively, mainly splitted by `,`. Generic params are comma
separated too, which failed to parse it correctly.
- Static methods were not handled correctly in the native side. It
naively skipped the first param, as if all the methods it deals with are
instance methods.
- The signature received by SymDb is surrounded by `(` and `)` and has
space in between every param type.

## Reason for change
SymDb readiness for Open Beta.

## Implementation details
- In the managed side, upon receiving a request to instrument a method
with a signature that is targeting a generic method/type, the `<` and
`>` characters are replaced with `[` and `]` respectively.
- Parsing the signature in a more robust way that handles the generic
case where comma could present in between every generic param.
- Static methods are now correctly handled in the native side when a
request arrives with a signature exact matching.
- Correctly parsing the signature when it comes surrounded by `(` and
`)`, including space in between every param type.

## Test coverage
-
[SignatureParserTests](https://github.com/DataDog/dd-trace-dotnet/blob/a8a2df542625b29e3f0d2ce8c745717f27abdb0a/tracer/test/Datadog.Trace.Debugger.IntegrationTests/SignatureParserTests.cs)
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