[Profiler] Add unit tests for ManagedCodeCache#8307
Conversation
6093f27 to
8674315
Compare
BenchmarksBenchmark execution time: 2026-03-16 15:33:47 Comparing candidate commit 23d840f in PR branch 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
scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody netcoreapp3.1
scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody net6.0
scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody netcoreapp3.1
scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody net6.0
scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody netcoreapp3.1
scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest net6.0
scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net6.0
scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces netcoreapp3.1
scenario:Benchmarks.Trace.RedisBenchmark.SendReceive net6.0
scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope net6.0
scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope netcoreapp3.1
scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin netcoreapp3.1
|
575d0f5 to
7be40cc
Compare
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (8307) 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 (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
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
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
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
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
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
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
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
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
chrisnas
left a comment
There was a problem hiding this comment.
LGTM: maybe add one final check for multi-thread scenario
|
|
||
| // Test: Initialization succeeds | ||
| TEST_F(ManagedCodeCacheTest, Initialize_Succeeds) { | ||
| ASSERT_NE(nullptr, cache); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
should be 0x5000 for "middle"
| } | ||
|
|
||
| // Test: Signal safety of IsManaged (no blocking) | ||
| TEST_F(ManagedCodeCacheTest, IsManaged_ConcurrentAccess_IsSignalSafe) { |
There was a problem hiding this comment.
Not sure this is related to "signa safe"
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
GetFunctionIdandIsManagedTest coverage
Other details