Skip to content

[Profiler] Add unit tests for ManagedCodeCache#8307

Merged
gleocadie merged 4 commits into
masterfrom
gleocadie/add_unit_tests_for_ManagedCodeCache
Mar 16, 2026
Merged

[Profiler] Add unit tests for ManagedCodeCache#8307
gleocadie merged 4 commits into
masterfrom
gleocadie/add_unit_tests_for_ManagedCodeCache

Conversation

@gleocadie

@gleocadie gleocadie commented Mar 16, 2026

Copy link
Copy Markdown
Collaborator

Summary of changes

Add unit tests for ManagedCodeCache.

Reason for change

We would like to enable ManagedCodeCache by default, but for that we need to do more tests. This is a first step in harnessing ManagedCodeCache

Implementation details

  • Mock ICorProfilerInfo
  • Create unit tests to tests GetFunctionId and IsManaged

Test coverage

Other details

@github-actions github-actions Bot added the area:profiler Issues related to the continous-profiler label Mar 16, 2026
@gleocadie
gleocadie force-pushed the gleocadie/add_unit_tests_for_ManagedCodeCache branch from 6093f27 to 8674315 Compare March 16, 2026 08:49
@pr-commenter

pr-commenter Bot commented Mar 16, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-03-16 15:33:47

Comparing candidate commit 23d840f in PR branch gleocadie/add_unit_tests_for_ManagedCodeCache with baseline commit 46f950d in branch master.

Found 8 performance improvements and 7 performance regressions! Performance is the same for 157 metrics, 20 unstable metrics.

scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces net6.0

  • 🟥 execution_time [+80.187ms; +81.330ms] or [+64.409%; +65.327%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody netcoreapp3.1

  • 🟥 execution_time [+10.012ms; +15.418ms] or [+5.012%; +7.718%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody net6.0

  • 🟩 execution_time [-24.192ms; -22.992ms] or [-10.775%; -10.240%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody netcoreapp3.1

  • 🟥 execution_time [+12.367ms; +18.544ms] or [+6.324%; +9.482%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody net6.0

  • 🟩 execution_time [-18.338ms; -13.364ms] or [-8.624%; -6.285%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody netcoreapp3.1

  • 🟥 throughput [-275103.915op/s; -198732.615op/s] or [-10.992%; -7.941%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest net6.0

  • 🟥 execution_time [+6.461ms; +9.786ms] or [+6.950%; +10.527%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net6.0

  • 🟩 throughput [+98.551op/s; +223.658op/s] or [+6.947%; +15.766%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces netcoreapp3.1

  • 🟩 execution_time [-33.129ms; -29.415ms] or [-19.870%; -17.642%]
  • 🟩 throughput [+195.246op/s; +233.886op/s] or [+13.561%; +16.245%]

scenario:Benchmarks.Trace.RedisBenchmark.SendReceive net6.0

  • 🟥 execution_time [+11.330ms; +17.121ms] or [+5.743%; +8.679%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope net6.0

  • 🟩 execution_time [-21.328ms; -17.357ms] or [-9.755%; -7.939%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope netcoreapp3.1

  • 🟥 throughput [-59593.042op/s; -44422.410op/s] or [-7.159%; -5.336%]
  • 🟩 execution_time [-16.367ms; -12.660ms] or [-7.624%; -5.897%]

scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin netcoreapp3.1

  • 🟩 execution_time [-17.752ms; -12.635ms] or [-8.415%; -5.989%]

@gleocadie
gleocadie force-pushed the gleocadie/add_unit_tests_for_ManagedCodeCache branch from 575d0f5 to 7be40cc Compare March 16, 2026 12:05
@gleocadie gleocadie changed the title Add unit tests for ManagedCodeCache [Profiler] Add unit tests for ManagedCodeCache Mar 16, 2026
@gleocadie
gleocadie marked this pull request as ready for review March 16, 2026 12:41
@gleocadie
gleocadie requested a review from a team as a code owner March 16, 2026 12:41
@dd-trace-dotnet-ci-bot

Copy link
Copy Markdown

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing This PR (8307) and master.

✅ No regressions detected - check the details below

Full Metrics Comparison

FakeDbCommand

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration74.35 ± (74.46 - 74.98) ms76.17 ± (76.21 - 76.59) ms+2.4%✅⬆️
.NET Framework 4.8 - Bailout
duration79.17 ± (79.02 - 79.39) ms80.88 ± (80.71 - 81.09) ms+2.2%✅⬆️
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1082.19 ± (1084.24 - 1091.08) ms1103.67 ± (1103.46 - 1109.77) ms+2.0%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms22.80 ± (22.75 - 22.84) ms23.51 ± (23.47 - 23.55) ms+3.1%✅⬆️
process.time_to_main_ms86.22 ± (86.00 - 86.44) ms90.08 ± (89.87 - 90.30) ms+4.5%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.89 ± (10.89 - 10.90) MB10.90 ± (10.90 - 10.91) MB+0.1%✅⬆️
runtime.dotnet.threads.count12 ± (12 - 12)12 ± (12 - 12)+0.0%
.NET Core 3.1 - Bailout
process.internal_duration_ms22.65 ± (22.61 - 22.70) ms23.34 ± (23.29 - 23.39) ms+3.1%✅⬆️
process.time_to_main_ms86.86 ± (86.64 - 87.09) ms90.47 ± (90.25 - 90.69) ms+4.1%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.93 ± (10.92 - 10.93) MB10.93 ± (10.93 - 10.94) MB+0.1%✅⬆️
runtime.dotnet.threads.count13 ± (13 - 13)13 ± (13 - 13)+0.0%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms226.37 ± (225.35 - 227.40) ms228.41 ± (227.23 - 229.60) ms+0.9%✅⬆️
process.time_to_main_ms495.92 ± (495.03 - 496.81) ms509.19 ± (508.07 - 510.32) ms+2.7%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed47.16 ± (47.13 - 47.18) MB47.18 ± (47.16 - 47.21) MB+0.1%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)-0.1%
.NET 6 - Baseline
process.internal_duration_ms21.50 ± (21.46 - 21.53) ms21.99 ± (21.95 - 22.04) ms+2.3%✅⬆️
process.time_to_main_ms74.19 ± (74.01 - 74.36) ms76.65 ± (76.47 - 76.83) ms+3.3%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.62 ± (10.61 - 10.62) MB10.63 ± (10.62 - 10.63) MB+0.1%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 6 - Bailout
process.internal_duration_ms21.47 ± (21.44 - 21.51) ms22.11 ± (22.06 - 22.16) ms+2.9%✅⬆️
process.time_to_main_ms75.30 ± (75.14 - 75.46) ms78.57 ± (78.37 - 78.77) ms+4.3%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.68 ± (10.67 - 10.68) MB10.74 ± (10.74 - 10.75) MB+0.6%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms206.64 ± (204.76 - 208.51) ms214.21 ± (212.45 - 215.96) ms+3.7%✅⬆️
process.time_to_main_ms493.78 ± (492.79 - 494.78) ms504.22 ± (503.35 - 505.10) ms+2.1%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed49.15 ± (49.10 - 49.20) MB49.29 ± (49.26 - 49.33) MB+0.3%✅⬆️
runtime.dotnet.threads.count29 ± (29 - 29)29 ± (29 - 29)+0.1%✅⬆️
.NET 8 - Baseline
process.internal_duration_ms19.59 ± (19.55 - 19.62) ms20.30 ± (20.26 - 20.35) ms+3.7%✅⬆️
process.time_to_main_ms73.26 ± (73.10 - 73.41) ms76.91 ± (76.75 - 77.08) ms+5.0%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.65 ± (7.65 - 7.66) MB7.65 ± (7.65 - 7.66) MB-0.0%
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 8 - Bailout
process.internal_duration_ms19.58 ± (19.54 - 19.62) ms20.46 ± (20.40 - 20.52) ms+4.5%✅⬆️
process.time_to_main_ms74.54 ± (74.41 - 74.68) ms78.50 ± (78.27 - 78.73) ms+5.3%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.71 ± (7.70 - 7.71) MB7.74 ± (7.73 - 7.75) MB+0.4%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms164.64 ± (163.84 - 165.44) ms169.38 ± (168.32 - 170.43) ms+2.9%✅⬆️
process.time_to_main_ms471.71 ± (470.97 - 472.46) ms487.03 ± (486.21 - 487.85) ms+3.2%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed36.57 ± (36.55 - 36.59) MB36.56 ± (36.54 - 36.58) MB-0.0%
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)-0.5%

HttpMessageHandler

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration191.16 ± (191.42 - 192.33) ms195.62 ± (195.41 - 196.34) ms+2.3%✅⬆️
.NET Framework 4.8 - Bailout
duration195.21 ± (195.00 - 195.61) ms198.12 ± (197.99 - 198.74) ms+1.5%✅⬆️
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1141.90 ± (1142.47 - 1149.19) ms1162.42 ± (1164.24 - 1173.16) ms+1.8%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms187.50 ± (187.13 - 187.87) ms192.40 ± (191.88 - 192.92) ms+2.6%✅⬆️
process.time_to_main_ms80.28 ± (80.13 - 80.44) ms82.55 ± (82.30 - 82.80) ms+2.8%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.14 ± (16.11 - 16.17) MB16.08 ± (16.06 - 16.09) MB-0.4%
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (20 - 20)+0.1%✅⬆️
.NET Core 3.1 - Bailout
process.internal_duration_ms186.49 ± (186.23 - 186.74) ms189.68 ± (189.27 - 190.09) ms+1.7%✅⬆️
process.time_to_main_ms81.38 ± (81.24 - 81.52) ms83.33 ± (83.13 - 83.52) ms+2.4%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.18 ± (16.16 - 16.21) MB16.14 ± (16.11 - 16.16) MB-0.3%
runtime.dotnet.threads.count21 ± (20 - 21)21 ± (21 - 21)+0.2%✅⬆️
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms394.46 ± (392.64 - 396.29) ms398.67 ± (396.67 - 400.67) ms+1.1%✅⬆️
process.time_to_main_ms470.44 ± (469.86 - 471.03) ms477.59 ± (476.98 - 478.20) ms+1.5%✅⬆️
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed57.69 ± (57.52 - 57.86) MB58.03 ± (57.89 - 58.17) MB+0.6%✅⬆️
runtime.dotnet.threads.count30 ± (29 - 30)30 ± (29 - 30)+0.0%✅⬆️
.NET 6 - Baseline
process.internal_duration_ms192.38 ± (192.03 - 192.74) ms197.63 ± (197.17 - 198.09) ms+2.7%✅⬆️
process.time_to_main_ms69.93 ± (69.75 - 70.10) ms71.93 ± (71.68 - 72.19) ms+2.9%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.12 ± (15.98 - 16.27) MB16.35 ± (16.32 - 16.37) MB+1.4%✅⬆️
runtime.dotnet.threads.count18 ± (18 - 18)19 ± (19 - 19)+6.1%✅⬆️
.NET 6 - Bailout
process.internal_duration_ms191.78 ± (191.42 - 192.14) ms196.44 ± (195.90 - 196.97) ms+2.4%✅⬆️
process.time_to_main_ms70.89 ± (70.79 - 71.00) ms72.67 ± (72.45 - 72.89) ms+2.5%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.23 ± (16.11 - 16.35) MB16.39 ± (16.37 - 16.42) MB+1.0%✅⬆️
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (20 - 20)+1.5%✅⬆️
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms430.19 ± (428.34 - 432.03) ms435.20 ± (433.59 - 436.80) ms+1.2%✅⬆️
process.time_to_main_ms474.41 ± (473.66 - 475.15) ms487.53 ± (486.37 - 488.70) ms+2.8%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed60.25 ± (60.17 - 60.33) MB60.06 ± (59.97 - 60.15) MB-0.3%
runtime.dotnet.threads.count30 ± (30 - 30)30 ± (30 - 30)+0.2%✅⬆️
.NET 8 - Baseline
process.internal_duration_ms189.65 ± (189.37 - 189.94) ms193.41 ± (192.96 - 193.87) ms+2.0%✅⬆️
process.time_to_main_ms69.19 ± (69.03 - 69.34) ms70.69 ± (70.55 - 70.84) ms+2.2%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.77 ± (11.74 - 11.80) MB11.71 ± (11.70 - 11.73) MB-0.5%
runtime.dotnet.threads.count18 ± (18 - 18)18 ± (18 - 18)+0.6%✅⬆️
.NET 8 - Bailout
process.internal_duration_ms189.16 ± (188.86 - 189.46) ms192.35 ± (191.88 - 192.82) ms+1.7%✅⬆️
process.time_to_main_ms70.68 ± (70.57 - 70.78) ms71.90 ± (71.75 - 72.06) ms+1.7%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.81 ± (11.78 - 11.84) MB11.76 ± (11.74 - 11.78) MB-0.4%
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)+0.8%✅⬆️
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms351.36 ± (350.09 - 352.62) ms358.88 ± (357.42 - 360.33) ms+2.1%✅⬆️
process.time_to_main_ms449.77 ± (449.09 - 450.45) ms461.43 ± (460.44 - 462.42) ms+2.6%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed48.46 ± (48.42 - 48.50) MB48.57 ± (48.54 - 48.61) MB+0.2%✅⬆️
runtime.dotnet.threads.count30 ± (30 - 30)30 ± (30 - 30)+0.1%✅⬆️
Comparison explanation

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

Duration charts
FakeDbCommand (.NET Framework 4.8)
gantt
    title Execution time (ms) FakeDbCommand (.NET Framework 4.8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8307) - mean (76ms)  : 74, 79
    master - mean (75ms)  : 71, 79

    section Bailout
    This PR (8307) - mean (81ms)  : 79, 83
    master - mean (79ms)  : 77, 81

    section CallTarget+Inlining+NGEN
    This PR (8307) - mean (1,107ms)  : 1061, 1152
    master - mean (1,088ms)  : 1039, 1137

Loading
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 (8307) - mean (121ms)  : 116, 126
    master - mean (116ms)  : 112, 120

    section Bailout
    This PR (8307) - mean (121ms)  : 117, 125
    master - mean (116ms)  : 113, 119

    section CallTarget+Inlining+NGEN
    This PR (8307) - mean (774ms)  : 744, 805
    master - mean (759ms)  : 732, 786

Loading
FakeDbCommand (.NET 6)
gantt
    title Execution time (ms) FakeDbCommand (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8307) - mean (105ms)  : 102, 108
    master - mean (102ms)  : 99, 105

    section Bailout
    This PR (8307) - mean (107ms)  : 104, 111
    master - mean (103ms)  : 101, 105

    section CallTarget+Inlining+NGEN
    This PR (8307) - mean (756ms)  : 716, 796
    master - mean (736ms)  : 686, 785

Loading
FakeDbCommand (.NET 8)
gantt
    title Execution time (ms) FakeDbCommand (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8307) - mean (105ms)  : 102, 109
    master - mean (101ms)  : 97, 104

    section Bailout
    This PR (8307) - mean (107ms)  : 103, 110
    master - mean (102ms)  : 100, 104

    section CallTarget+Inlining+NGEN
    This PR (8307) - mean (695ms)  : 665, 725
    master - mean (678ms)  : 649, 708

Loading
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 (8307) - mean (196ms)  : 191, 201
    master - mean (192ms)  : 187, 197

    section Bailout
    This PR (8307) - mean (198ms)  : 195, 202
    master - mean (195ms)  : 192, 198

    section CallTarget+Inlining+NGEN
    This PR (8307) - mean (1,169ms)  : 1103, 1234
    master - mean (1,146ms)  : 1098, 1194

Loading
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 (8307) - mean (284ms)  : 271, 297
    master - mean (276ms)  : 271, 281

    section Bailout
    This PR (8307) - mean (282ms)  : 275, 288
    master - mean (276ms)  : 273, 280

    section CallTarget+Inlining+NGEN
    This PR (8307) - mean (911ms)  : 881, 941
    master - mean (898ms)  : 871, 925

Loading
HttpMessageHandler (.NET 6)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8307) - mean (278ms)  : 269, 287
    master - mean (270ms)  : 266, 274

    section Bailout
    This PR (8307) - mean (278ms)  : 271, 284
    master - mean (271ms)  : 267, 275

    section CallTarget+Inlining+NGEN
    This PR (8307) - mean (957ms)  : 920, 995
    master - mean (936ms)  : 910, 963

Loading
HttpMessageHandler (.NET 8)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8307) - mean (274ms)  : 266, 283
    master - mean (269ms)  : 264, 273

    section Bailout
    This PR (8307) - mean (274ms)  : 265, 283
    master - mean (269ms)  : 265, 273

    section CallTarget+Inlining+NGEN
    This PR (8307) - mean (853ms)  : 820, 886
    master - mean (831ms)  : 809, 854

Loading

@chrisnas chrisnas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM: maybe add one final check for multi-thread scenario


// Test: Initialization succeeds
TEST_F(ManagedCodeCacheTest, Initialize_Succeeds) {
ASSERT_NE(nullptr, cache);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it really needed?
How could the Setup() fail?
cache = std::make_unique<ManagedCodeCache>(mockProfiler);

WaitForWorkerThread(500); // Wait longer for all async operations

// Verify no crashes and cache is still functional
EXPECT_NE(nullptr, cache);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not validating the content of the cache to ensure that no override happened?


// Test various points in large range
EXPECT_EQ(testFuncId, cache->GetFunctionId(codeStart).value_or(0));
EXPECT_EQ(testFuncId, cache->GetFunctionId(codeStart + 0x8000).value_or(0)); // Middle

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should be 0x5000 for "middle"

}

// Test: Signal safety of IsManaged (no blocking)
TEST_F(ManagedCodeCacheTest, IsManaged_ConcurrentAccess_IsSignalSafe) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure this is related to "signa safe"

@gleocadie
gleocadie merged commit 7c71596 into master Mar 16, 2026
146 checks passed
@gleocadie
gleocadie deleted the gleocadie/add_unit_tests_for_ManagedCodeCache branch March 16, 2026 17:55
@github-actions github-actions Bot added this to the vNext-v3 milestone Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:profiler Issues related to the continous-profiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants