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] DEBUG-3132 Add Memoization Cache for Redaction Logic #6292

Merged
merged 5 commits into from
Feb 13, 2025

Conversation

dudikeleti
Copy link
Contributor

Summary of changes

This PR introduces caching functionality to optimize redaction decisions by implementing memoization using our Adaptive Cache system.

Reason for change

Redaction decision-making can be computationally expensive.

@github-actions github-actions bot added area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) area:debugger labels Nov 15, 2024
@dudikeleti dudikeleti force-pushed the dudik/redaction-chache branch from 5d8e91e to 0052195 Compare February 7, 2025 17:20
@dudikeleti dudikeleti marked this pull request as ready for review February 7, 2025 17:41
@dudikeleti dudikeleti requested a review from a team as a code owner February 7, 2025 17:41
@andrewlock
Copy link
Member

andrewlock commented Feb 7, 2025

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 (6292) - mean (69ms)  : 66, 72
     .   : milestone, 69,
    master - mean (69ms)  : 66, 72
     .   : milestone, 69,

    section CallTarget+Inlining+NGEN
    This PR (6292) - mean (996ms)  : 976, 1016
     .   : milestone, 996,
    master - mean (992ms)  : 960, 1024
     .   : milestone, 992,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6292) - mean (102ms)  : 101, 104
     .   : milestone, 102,
    master - mean (102ms)  : 100, 104
     .   : milestone, 102,

    section CallTarget+Inlining+NGEN
    This PR (6292) - mean (673ms)  : 654, 693
     .   : milestone, 673,
    master - mean (674ms)  : 659, 690
     .   : milestone, 674,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6292) - mean (89ms)  : 86, 91
     .   : milestone, 89,
    master - mean (89ms)  : 87, 91
     .   : milestone, 89,

    section CallTarget+Inlining+NGEN
    This PR (6292) - mean (632ms)  : 617, 647
     .   : milestone, 632,
    master - mean (630ms)  : 615, 645
     .   : milestone, 630,

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

    section CallTarget+Inlining+NGEN
    This PR (6292) - mean (1,112ms)  : 1082, 1142
     .   : milestone, 1112,
    master - mean (1,105ms)  : 1077, 1133
     .   : milestone, 1105,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6292) - mean (272ms)  : 267, 277
     .   : milestone, 272,
    master - mean (272ms)  : 266, 278
     .   : milestone, 272,

    section CallTarget+Inlining+NGEN
    This PR (6292) - mean (866ms)  : 832, 900
     .   : milestone, 866,
    master - mean (868ms)  : 834, 903
     .   : milestone, 868,

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

    section CallTarget+Inlining+NGEN
    This PR (6292) - mean (848ms)  : 815, 882
     .   : milestone, 848,
    master - mean (849ms)  : 811, 886
     .   : milestone, 849,

Loading

@andrewlock
Copy link
Member

andrewlock commented Feb 7, 2025

Benchmarks Report for tracer 🐌

Benchmarks for #6292 compared to master:

  • 2 benchmarks are slower, with geometric mean 1.176
  • 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.85μs 42.1ns 219ns 0.0191 0.00762 0 5.61 KB
master StartStopWithChild netcoreapp3.1 10.1μs 50.2ns 230ns 0.0206 0.0103 0 5.81 KB
master StartStopWithChild net472 16μs 35ns 136ns 1.06 0.319 0.104 6.22 KB
#6292 StartStopWithChild net6.0 8.18μs 45.7ns 292ns 0.0164 0.00821 0 5.61 KB
#6292 StartStopWithChild netcoreapp3.1 10.6μs 60.1ns 433ns 0.0205 0.0103 0 5.8 KB
#6292 StartStopWithChild net472 16.5μs 70.3ns 629ns 1.05 0.325 0.0952 6.22 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 490μs 533ns 1.99μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 638μs 842ns 3.03μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 870μs 674ns 2.61μs 0.431 0 0 3.3 KB
#6292 WriteAndFlushEnrichedTraces net6.0 502μs 618ns 2.31μs 0 0 0 2.7 KB
#6292 WriteAndFlushEnrichedTraces netcoreapp3.1 643μs 651ns 2.43μs 0 0 0 2.7 KB
#6292 WriteAndFlushEnrichedTraces net472 847μs 505ns 1.95μs 0.419 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 130μs 544ns 2.11μs 0.193 0 0 14.47 KB
master SendRequest netcoreapp3.1 144μs 384ns 1.49μs 0.218 0 0 17.27 KB
master SendRequest net472 0.000231ns 9.39E‑05ns 0.000338ns 0 0 0 0 b
#6292 SendRequest net6.0 132μs 528ns 2.04μs 0.187 0 0 14.47 KB
#6292 SendRequest netcoreapp3.1 150μs 151ns 585ns 0.15 0 0 17.27 KB
#6292 SendRequest net472 0ns 0ns 0ns 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 560μs 2.7μs 11.8μs 0.571 0 0 41.64 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 690μs 3.77μs 22μs 0.322 0 0 41.74 KB
master WriteAndFlushEnrichedTraces net472 868μs 4.14μs 16.5μs 8.13 2.57 0.428 53.32 KB
#6292 WriteAndFlushEnrichedTraces net6.0 557μs 3.02μs 17.3μs 0.302 0 0 41.52 KB
#6292 WriteAndFlushEnrichedTraces netcoreapp3.1 693μs 3.85μs 24.9μs 0.345 0 0 41.79 KB
#6292 WriteAndFlushEnrichedTraces net472 830μs 2.36μs 8.82μs 8.22 2.47 0.411 53.32 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.39μs 1.27ns 4.93ns 0.0145 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.76μs 1.94ns 7.52ns 0.014 0 0 1.02 KB
master ExecuteNonQuery net472 2.16μs 1.34ns 4.84ns 0.156 0.00108 0 987 B
#6292 ExecuteNonQuery net6.0 1.36μs 1.64ns 6.35ns 0.0143 0 0 1.02 KB
#6292 ExecuteNonQuery netcoreapp3.1 1.78μs 2.23ns 8.66ns 0.0133 0 0 1.02 KB
#6292 ExecuteNonQuery net472 2.04μs 1.52ns 5.9ns 0.156 0.00101 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.25μs 1.05ns 4.06ns 0.0138 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.57μs 0.798ns 3.09ns 0.0133 0 0 976 B
master CallElasticsearch net472 2.58μs 1.9ns 7.34ns 0.157 0 0 995 B
master CallElasticsearchAsync net6.0 1.34μs 0.193ns 0.696ns 0.0134 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.66μs 0.63ns 2.36ns 0.0133 0 0 1.02 KB
master CallElasticsearchAsync net472 2.49μs 2.37ns 9.19ns 0.166 0 0 1.05 KB
#6292 CallElasticsearch net6.0 1.3μs 0.603ns 2.26ns 0.0137 0 0 976 B
#6292 CallElasticsearch netcoreapp3.1 1.58μs 0.688ns 2.57ns 0.0127 0 0 976 B
#6292 CallElasticsearch net472 2.46μs 2.12ns 8.22ns 0.157 0 0 995 B
#6292 CallElasticsearchAsync net6.0 1.33μs 0.737ns 2.66ns 0.0133 0 0 952 B
#6292 CallElasticsearchAsync netcoreapp3.1 1.71μs 0.757ns 2.93ns 0.0137 0 0 1.02 KB
#6292 CallElasticsearchAsync net472 2.51μs 1.59ns 6.17ns 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.29μs 0.968ns 3.62ns 0.0129 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.58μs 0.395ns 1.42ns 0.0126 0 0 952 B
master ExecuteAsync net472 1.89μs 0.865ns 3.35ns 0.145 0 0 915 B
#6292 ExecuteAsync net6.0 1.23μs 1.03ns 4.01ns 0.0136 0 0 952 B
#6292 ExecuteAsync netcoreapp3.1 1.67μs 1.81ns 7.02ns 0.0132 0 0 952 B
#6292 ExecuteAsync net472 1.87μs 0.729ns 2.73ns 0.145 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 4.32μs 1.78ns 6.65ns 0.0323 0 0 2.31 KB
master SendAsync netcoreapp3.1 5.2μs 2.58ns 9.97ns 0.0363 0 0 2.85 KB
master SendAsync net472 7.38μs 1.06ns 4.11ns 0.495 0 0 3.12 KB
#6292 SendAsync net6.0 4.35μs 1.2ns 4.51ns 0.0327 0 0 2.31 KB
#6292 SendAsync netcoreapp3.1 5.23μs 1.92ns 7.42ns 0.0368 0 0 2.85 KB
#6292 SendAsync net472 7.4μs 1.79ns 6.93ns 0.493 0 0 3.12 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.52μs 0.519ns 1.87ns 0.0228 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.28μs 1.29ns 4.81ns 0.0228 0 0 1.64 KB
master EnrichedLog net472 2.62μs 0.827ns 3.2ns 0.249 0 0 1.57 KB
#6292 EnrichedLog net6.0 1.58μs 0.589ns 2.28ns 0.0231 0 0 1.64 KB
#6292 EnrichedLog netcoreapp3.1 2.2μs 1.08ns 4.16ns 0.0221 0 0 1.64 KB
#6292 EnrichedLog net472 2.58μs 1.55ns 5.99ns 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 115μs 208ns 805ns 0.0565 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 117μs 194ns 750ns 0 0 0 4.28 KB
master EnrichedLog net472 149μs 130ns 505ns 0.671 0.224 0 4.46 KB
#6292 EnrichedLog net6.0 113μs 215ns 832ns 0.0561 0 0 4.28 KB
#6292 EnrichedLog netcoreapp3.1 118μs 88.4ns 342ns 0 0 0 4.28 KB
#6292 EnrichedLog net472 150μs 127ns 491ns 0.677 0.226 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.03μs 0.658ns 2.55ns 0.0303 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.18μs 2.45ns 9.49ns 0.0292 0 0 2.2 KB
master EnrichedLog net472 4.91μs 2.19ns 8.2ns 0.321 0 0 2.02 KB
#6292 EnrichedLog net6.0 3.03μs 0.7ns 2.71ns 0.0309 0 0 2.2 KB
#6292 EnrichedLog netcoreapp3.1 4.15μs 1.43ns 5.52ns 0.0291 0 0 2.2 KB
#6292 EnrichedLog net472 4.99μs 1.76ns 6.59ns 0.321 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.39μs 1.06ns 4.12ns 0.0159 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.87μs 0.486ns 1.75ns 0.015 0 0 1.14 KB
master SendReceive net472 2.11μs 1.4ns 5.43ns 0.183 0 0 1.16 KB
#6292 SendReceive net6.0 1.31μs 0.442ns 1.65ns 0.0157 0 0 1.14 KB
#6292 SendReceive netcoreapp3.1 1.8μs 1.77ns 6.85ns 0.0153 0 0 1.14 KB
#6292 SendReceive net472 2.12μs 0.922ns 3.32ns 0.184 0 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.73μs 0.903ns 3.5ns 0.0218 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 3.99μs 2.21ns 8.54ns 0.022 0 0 1.65 KB
master EnrichedLog net472 4.42μs 4.19ns 16.2ns 0.323 0 0 2.04 KB
#6292 EnrichedLog net6.0 2.91μs 0.814ns 3.15ns 0.0221 0 0 1.6 KB
#6292 EnrichedLog netcoreapp3.1 3.8μs 1.18ns 4.41ns 0.0208 0 0 1.65 KB
#6292 EnrichedLog net472 4.3μs 1.93ns 7.22ns 0.324 0 0 2.04 KB
Benchmarks.Trace.SpanBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #6292

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑netcoreapp3.1 1.181 551.10 651.03
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net472 1.170 627.43 734.13 several?

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 502ns 0.492ns 1.91ns 0.00812 0 0 576 B
master StartFinishSpan netcoreapp3.1 552ns 1.81ns 6.79ns 0.00767 0 0 576 B
master StartFinishSpan net472 627ns 1.15ns 4.46ns 0.0918 0 0 578 B
master StartFinishScope net6.0 478ns 0.861ns 3.33ns 0.00965 0 0 696 B
master StartFinishScope netcoreapp3.1 675ns 1.14ns 4.27ns 0.00923 0 0 696 B
master StartFinishScope net472 804ns 2.86ns 11.1ns 0.104 0 0 658 B
#6292 StartFinishSpan net6.0 460ns 0.145ns 0.561ns 0.00802 0 0 576 B
#6292 StartFinishSpan netcoreapp3.1 651ns 1.06ns 4.12ns 0.00786 0 0 576 B
#6292 StartFinishSpan net472 728ns 3.63ns 15.8ns 0.0915 0 0 578 B
#6292 StartFinishScope net6.0 523ns 0.233ns 0.872ns 0.00981 0 0 696 B
#6292 StartFinishScope netcoreapp3.1 716ns 0.361ns 1.4ns 0.00952 0 0 696 B
#6292 StartFinishScope net472 825ns 3.96ns 15.3ns 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 662ns 0.979ns 3.79ns 0.00971 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 921ns 1.27ns 4.91ns 0.00924 0 0 696 B
master RunOnMethodBegin net472 1.08μs 1.63ns 6.32ns 0.104 0 0 658 B
#6292 RunOnMethodBegin net6.0 677ns 0.718ns 2.78ns 0.0095 0 0 696 B
#6292 RunOnMethodBegin netcoreapp3.1 936ns 0.968ns 3.75ns 0.00942 0 0 696 B
#6292 RunOnMethodBegin net472 1.1μs 0.532ns 2.06ns 0.104 0 0 658 B

@datadog-ddstaging
Copy link

datadog-ddstaging bot commented Feb 7, 2025

Datadog Report

Branch report: dudik/redaction-chache
Commit report: d84d94d
Test service: dd-trace-dotnet

❌ 126 Failed (0 Known Flaky), 227758 Passed, 3345 Skipped, 31h 52m 56.27s Total Time

❌ Failed Tests (126)

This report shows up to 5 failed tests.

  • RedactedKeywords_LongStrings_Test - Datadog.Trace.Tests.Debugger.RedactionTests - Details

    Expand for error
     Assert.Equal() Failure
     Expected: False
     Actual:   True
    
  • RedactedKeywords_LongStrings_Test - Datadog.Trace.Tests.Debugger.RedactionTests - Details

    Expand for error
     Assert.Equal() Failure
     Expected: False
     Actual:   True
    
  • RedactedKeywords_LongStrings_Test - Datadog.Trace.Tests.Debugger.RedactionTests - Details

    Expand for error
     Assert.Equal() Failure
     Expected: False
     Actual:   True
    
  • RedactedKeywords_LongStrings_Test - Datadog.Trace.Tests.Debugger.RedactionTests - Details

    Expand for error
     Assert.Equal() Failure
     Expected: False
     Actual:   True
    
  • RedactedKeywords_LongStrings_Test - Datadog.Trace.Tests.Debugger.RedactionTests - Details

    Expand for error
     Assert.Equal() Failure
     Expected: False
     Actual:   True
    

@dudikeleti dudikeleti force-pushed the dudik/redaction-chache branch from 454edff to 8c1de94 Compare February 10, 2025 12:34
@dudikeleti dudikeleti force-pushed the dudik/redaction-chache branch from b8175dc to 9cc9a1a Compare February 13, 2025 09:19
@dudikeleti dudikeleti force-pushed the dudik/redaction-chache branch from 9cc9a1a to a8d5c98 Compare February 13, 2025 15:08
@dudikeleti dudikeleti merged commit 9d84a8d into master Feb 13, 2025
143 of 147 checks passed
@dudikeleti dudikeleti deleted the dudik/redaction-chache branch February 13, 2025 17:28
@github-actions github-actions bot added this to the vNext-v3 milestone Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:debugger area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants