Skip to content

[Profiler] Fix start/stop crash at shutdown - #9037

Open
gleocadie wants to merge 7 commits into
masterfrom
gleocadie/fix-shutdown-crash
Open

[Profiler] Fix start/stop crash at shutdown#9037
gleocadie wants to merge 7 commits into
masterfrom
gleocadie/fix-shutdown-crash

Conversation

@gleocadie

@gleocadie gleocadie commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Summary of changes

Fixes a shutdown-time SIGSEGV in the Continuous Profiler: StackSamplerLoop is promoted from a private implementation detail of StackSamplerLoopManager to its own independently-registered IService, so its start/stop lifecycle is owned directly by CorProfilerCallback's existing StartServices()/StopServices() machinery instead of an ad hoc, asynchronous internal sequence. Two related data races (volatile boolstd::atomic<bool>) are also fixed, found while adding tests for the new lifecycle.

Reason for change

A customer crash report showed the sampler thread segfaulting inside StackSamplerLoop::CodeHotspotIteration() while the process's main thread was, at the same instant, blocked in CLR shutdown joining that same thread. Two compounding issues caused it:

  • StackSamplerLoop::Start() was called asynchronously from inside a freshly-spawned watcher thread, with nothing guaranteeing it had actually run before StackSamplerLoopManager::StartImpl() returned.
  • CorProfilerCallback::Shutdown() calls StackSamplerLoopManager::Stop() explicitly and early. If the watcher thread hadn't reached Start() yet (an unbounded race, worse under CPU contention), that Stop() silently no-opped — the sampler's one-shot guard rejected it — and the watcher went on to start it anyway, after shutdown had already begun tearing down the ManagedThreadList instances it depends on. The only thing left to stop it at that point was ~StackSamplerLoop()'s last-resort destructor call, by which time those dependencies could already be gone.

Implementation details

  • StackSamplerLoop becomes a real service. It already inherited ServiceBase; it just wasn't registered. CorProfilerCallback::InitializeServices() now registers it right after StackSamplerLoopManager:
    • Start (forward order): the manager starts first — spawns the watcher and blocks until it's actually running — then the sampler starts, called directly and synchronously. No more watcher-thread indirection.
    • Stop (existing reverse-order loop, unchanged): the sampleeeps the watcher alive in case it needs to rescue a deadlockedsample) and well before ManagedThreadList's Stop()/destruction, since that was registered much earlier and so is stopped much later — guaranteeing the
      sampler is fully dead before anything it depends on is touched.
  • Watcher startup is a bounded wait, not fire-and-forget. RunWatcher() (renamed from RunWatcherAndSampler()) spawns the watcher thread and blocks on a
    std::promise/std::future handshake until it signals it's runn idiom ManagedCodeCache::Initialize() already uses elsewhere. Atimeout logs an error and returns false instead of hanging Initialize() forever; the possibly-still-starting thread is joined later, deferred to Stop() or
    the destructor.
  • Cross-wiring: StackSamplerLoop takes a StackSamplerLoopManager* at construction; the manager gets a StackSamplerLoop* back via a one-time
    SetStackSamplerLoop() setter, since the loop doesn't exist yet tartImpl()` checks this was actually called and fails cleanly witha logged error rather than null-deref'ing if a future refactor drops it.
  • Ownership shuffle: StackFramesCollectorBase/CallstackProrCallback (constructed once, shared by both services as rawnon-owning pointers), since the manager no longer constructs StackSamplerLoop itself.
  • Two data races fixed along the way, caught by TSan while wrcise this code path directly:StackSamplerLoop::_shutdownRequested and StackSamplerLoopManager::_isWatcherShutdownRequested, both volatile boolstd::atomic<bool>. Straight type
    swap, no behavior change.
  • CorProfilerCallback::Shutdown()'s existing early Stop() call (needed so the final .pprof captures the last samples) now stops both services explicitly;
    StopServices() calling them again later is a guaranteed no-op.

Test coverage

New file StackSamplerLoopManagerTest.cpp exercises the new lifeng a full CorProfilerCallback:

  • StartFailsCleanlyWhenStackSamplerLoopWasNeverWiredIn — the safety-net check when SetStackSamplerLoop() is skipped.
  • StackSamplerLoopStartsAndStopsIndependentlyOfTheManager — thet/stop lifecycle, testable in isolation from the manager.
  • FullLifecycleMatchesStartServicesAndStopServicesOrdering — full start (forward order) / stop (reverse order) cycle matching production's
    StartServices()/StopServices() sequencing.

Worth running locally with TSan (-DRUN_TSAN=1) to confirm the tob currently filters to *RingBuffer* only, so it won't exercisethese new tests until that filter is widened.

Other details

  • No intended behavior change on the non-crash path — this only changes ordering/synchronization of an already-existing start/stop sequence.
  • Not attempting a deterministic repro of the original race in CI contention during CLR shutdown to surface, and forcing that timing window would just produce a flaky test.
  • Windows build not yet verified for the new test file — Linux ane test CMake targets.

@github-actions github-actions Bot added the area:profiler Issues related to the continous-profiler label Aug 13, 2026
@dd-trace-dotnet-ci-bot

dd-trace-dotnet-ci-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

Execution-Time Benchmarks Report ⏱️

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

✅ No regressions detected

📄 View the full report (charts + all metrics) →

@pr-commenter

pr-commenter Bot commented Aug 13, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-08-13 17:24:21

Comparing candidate commit 28b84df in PR branch gleocadie/fix-shutdown-crash with baseline commit a099858 in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 1 performance regressions! Performance is the same for 71 metrics, 0 unstable metrics, 65 known flaky benchmarks, 61 flaky benchmarks without significant changes.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

scenario:Benchmarks.Trace.DbCommandBenchmark.ExecuteNonQuery net472

  • 🟥 throughput [-27671.009op/s; -24352.111op/s] or [-7.794%; -6.859%]

Known flaky benchmarks

These benchmarks are marked as flaky and will not trigger a failure. Modify FLAKY_BENCHMARKS_REGEX to control which benchmarks are marked as flaky.

scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild net472

  • 🟥 throughput [-6978.634op/s; -6422.798op/s] or [-8.275%; -7.616%]

scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild netcoreapp3.1

  • 🟥 throughput [-11398.742op/s; -9647.908op/s] or [-11.590%; -9.810%]

scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • 🟥 execution_time [+311.781ms; +319.358ms] or [+154.717%; +158.477%]
  • 🟥 throughput [-44.071op/s; -40.338op/s] or [-7.929%; -7.258%]

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

  • 🟥 execution_time [+380.919ms; +382.662ms] or [+300.949%; +302.326%]
  • 🟩 throughput [+89.882op/s; +92.837op/s] or [+11.851%; +12.240%]

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

  • 🟥 execution_time [+394.420ms; +395.584ms] or [+349.046%; +350.077%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody net472

  • 🟥 allocated_mem [+4.692KB; +4.693KB] or [+98.785%; +98.801%]
  • 🟥 throughput [-60647.593op/s; -60241.969op/s] or [-47.187%; -46.871%]

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

  • 🟥 allocated_mem [+3.816KB; +3.816KB] or [+80.699%; +80.711%]
  • 🟩 execution_time [-15.554ms; -11.356ms] or [-7.264%; -5.304%]
  • 🟥 throughput [-60048.286op/s; -57257.363op/s] or [-43.832%; -41.795%]

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

  • 🟥 allocated_mem [+4.544KB; +4.544KB] or [+98.261%; +98.274%]
  • 🟥 throughput [-48479.824op/s; -46227.460op/s] or [-43.831%; -41.795%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody net472

  • 🟥 allocated_mem [+1.315KB; +1.315KB] or [+106.388%; +106.404%]
  • 🟥 throughput [-254801.585op/s; -251219.545op/s] or [-26.016%; -25.651%]

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

  • 🟥 allocated_mem [+479 bytes; +480 bytes] or [+39.212%; +39.221%]
  • 🟩 execution_time [-25.815ms; -20.930ms] or [-11.512%; -9.334%]

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

  • 🟥 allocated_mem [+1.280KB; +1.280KB] or [+105.947%; +105.963%]
  • 🟥 throughput [-161282.987op/s; -144977.345op/s] or [-23.173%; -20.830%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody net472

  • 🟥 allocated_mem [+3.378KB; +3.378KB] or [+89.003%; +89.017%]
  • 🟥 throughput [-72844.739op/s; -72072.627op/s] or [-49.024%; -48.504%]

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

  • 🟥 allocated_mem [+3.336KB; +3.336KB] or [+88.150%; +88.161%]
  • 🟥 throughput [-73280.954op/s; -70404.495op/s] or [-46.627%; -44.797%]

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

  • 🟥 allocated_mem [+3.264KB; +3.264KB] or [+88.493%; +88.506%]
  • 🟥 throughput [-55547.008op/s; -52927.963op/s] or [-44.250%; -42.164%]

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

  • 🟩 throughput [+364724.858op/s; +381913.368op/s] or [+12.161%; +12.735%]

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

  • 🟩 execution_time [-18.837ms; -14.499ms] or [-8.683%; -6.684%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeArgs net472

  • 🟩 allocated_mem [-13.759KB; -13.757KB] or [-42.326%; -42.318%]
  • 🟥 execution_time [+299.934ms; +300.721ms] or [+149.867%; +150.260%]
  • 🟩 throughput [+1003.995op/s; +1029.708op/s] or [+11.089%; +11.373%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeArgs net6.0

  • 🟩 allocated_mem [-13.722KB; -13.718KB] or [-42.341%; -42.329%]
  • 🟥 execution_time [+299.897ms; +303.091ms] or [+151.239%; +152.849%]
  • 🟩 throughput [+2343.760op/s; +2560.627op/s] or [+17.926%; +19.585%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeArgs netcoreapp3.1

  • 🟩 allocated_mem [-13.722KB; -13.718KB] or [-42.341%; -42.329%]
  • 🟥 execution_time [+300.642ms; +303.196ms] or [+151.440%; +152.726%]
  • 🟩 throughput [+1804.637op/s; +1932.007op/s] or [+17.423%; +18.653%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeLegacyArgs net472

  • 🟥 execution_time [+296.395ms; +297.341ms] or [+145.577%; +146.042%]
  • 🟩 throughput [+589.661op/s; +600.419op/s] or [+15.632%; +15.917%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeLegacyArgs net6.0

  • 🟥 execution_time [+295.830ms; +297.336ms] or [+144.621%; +145.356%]
  • 🟩 throughput [+2567.273op/s; +2708.621op/s] or [+37.298%; +39.351%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeLegacyArgs netcoreapp3.1

  • 🟥 execution_time [+301.076ms; +301.862ms] or [+150.478%; +150.870%]
  • 🟩 throughput [+1388.743op/s; +1410.469op/s] or [+27.565%; +27.997%]

scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark net472

  • 🟩 execution_time [-146.969µs; -143.119µs] or [-30.175%; -29.384%]
  • 🟩 throughput [+858.679op/s; +883.679op/s] or [+41.822%; +43.039%]

scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark net6.0

  • 🟩 execution_time [-138.336µs; -111.682µs] or [-31.728%; -25.614%]
  • 🟩 throughput [+854.913op/s; +976.945op/s] or [+37.168%; +42.474%]

scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark netcoreapp3.1

  • 🟩 execution_time [-143.301µs; -121.183µs] or [-30.703%; -25.964%]
  • 🟩 throughput [+781.703op/s; +866.577op/s] or [+36.085%; +40.003%]

scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack net472

  • 🟩 execution_time [-127.882µs; -123.102µs] or [-34.527%; -33.237%]
  • 🟩 throughput [+1355.806op/s; +1415.885op/s] or [+50.213%; +52.438%]

scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack net6.0

  • 🟩 execution_time [-102.083µs; -78.483µs] or [-32.590%; -25.056%]
  • 🟩 throughput [+1177.573op/s; +1379.444op/s] or [+36.708%; +43.001%]

scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack netcoreapp3.1

  • 🟩 execution_time [-138.202µs; -115.810µs] or [-37.806%; -31.681%]
  • 🟩 throughput [+1337.851op/s; +1474.899op/s] or [+48.010%; +52.928%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest net472

  • 🟥 execution_time [+299.824ms; +300.608ms] or [+149.643%; +150.034%]

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

  • 🟥 execution_time [+413.896ms; +420.001ms] or [+449.715%; +456.348%]
  • 🟩 throughput [+810.869op/s; +988.040op/s] or [+6.663%; +8.119%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest netcoreapp3.1

  • 🟥 execution_time [+366.931ms; +371.146ms] or [+278.607%; +281.808%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • 🟥 allocated_mem [+2.822KB; +2.827KB] or [+5.014%; +5.023%]
  • unstable execution_time [+346.828ms; +408.802ms] or [+159.468%; +187.963%]
  • 🟥 throughput [-565.347op/s; -511.657op/s] or [-51.226%; -46.361%]

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

  • unstable execution_time [+203.209ms; +336.477ms] or [+86.599%; +143.392%]
  • 🟥 throughput [-665.652op/s; -582.218op/s] or [-44.399%; -38.834%]

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

  • 🟥 allocated_mem [+2.305KB; +2.308KB] or [+5.442%; +5.450%]
  • 🟥 execution_time [+336.498ms; +345.731ms] or [+201.265%; +206.787%]
  • 🟥 throughput [-376.991op/s; -340.942op/s] or [-26.249%; -23.739%]

scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice net6.0

  • 🟩 execution_time [-161.220µs; -105.574µs] or [-8.167%; -5.348%]
  • 🟩 throughput [+30.931op/s; +45.239op/s] or [+6.106%; +8.931%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch net472

  • 🟥 execution_time [+302.191ms; +305.817ms] or [+152.178%; +154.004%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch net6.0

  • unstable execution_time [+299.891ms; +330.448ms] or [+150.276%; +165.588%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch netcoreapp3.1

  • 🟥 execution_time [+301.418ms; +305.348ms] or [+151.420%; +153.394%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync net472

  • 🟥 execution_time [+301.523ms; +303.533ms] or [+151.415%; +152.424%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync net6.0

  • unstable execution_time [+297.383ms; +319.132ms] or [+147.043%; +157.796%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync netcoreapp3.1

  • 🟥 execution_time [+300.240ms; +314.120ms] or [+152.175%; +159.210%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync net472

  • 🟥 execution_time [+303.217ms; +306.368ms] or [+152.187%; +153.769%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync net6.0

  • 🟥 execution_time [+297.577ms; +316.365ms] or [+148.315%; +157.679%]
  • 🟩 throughput [+38247.945op/s; +53555.092op/s] or [+7.595%; +10.634%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync netcoreapp3.1

  • 🟥 execution_time [+301.087ms; +306.431ms] or [+149.788%; +152.447%]

scenario:Benchmarks.Trace.ILoggerBenchmark.EnrichedLog net6.0

  • 🟩 execution_time [-15.355ms; -11.609ms] or [-7.140%; -5.398%]
  • 🟩 throughput [+19296.691op/s; +26368.582op/s] or [+5.294%; +7.234%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark net472

  • unstable execution_time [+15.822µs; +57.809µs] or [+3.908%; +14.279%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark net6.0

  • 🟩 allocated_mem [-17.700KB; -17.677KB] or [-6.457%; -6.448%]
  • unstable execution_time [-39.416µs; +21.155µs] or [-7.790%; +4.181%]
  • unstable throughput [-64.423op/s; +148.668op/s] or [-3.215%; +7.419%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark netcoreapp3.1

  • 🟩 allocated_mem [-26.286KB; -26.267KB] or [-9.582%; -9.576%]
  • unstable execution_time [-55.456µs; +5.686µs] or [-9.610%; +0.985%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark net6.0

  • unstable execution_time [+10.453µs; +14.998µs] or [+24.707%; +35.450%]
  • 🟥 throughput [-6360.153op/s; -4475.088op/s] or [-26.774%; -18.839%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark netcoreapp3.1

  • unstable execution_time [-12.555µs; -3.551µs] or [-19.479%; -5.509%]
  • unstable throughput [+972.883op/s; +2906.126op/s] or [+5.969%; +17.830%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog net472

  • 🟥 execution_time [+301.884ms; +303.231ms] or [+152.589%; +153.270%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog net6.0

  • 🟥 execution_time [+300.518ms; +303.229ms] or [+152.963%; +154.343%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog netcoreapp3.1

  • 🟥 execution_time [+299.116ms; +301.329ms] or [+149.745%; +150.852%]

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

  • 🟩 throughput [+35955.665op/s; +41861.994op/s] or [+6.806%; +7.924%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog net472

  • 🟥 execution_time [+298.177ms; +300.123ms] or [+148.615%; +149.584%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog net6.0

  • 🟥 execution_time [+302.062ms; +304.384ms] or [+151.681%; +152.847%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog netcoreapp3.1

  • 🟥 execution_time [+302.016ms; +304.633ms] or [+153.163%; +154.490%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore net472

  • 🟥 execution_time [+299.785ms; +300.841ms] or [+149.534%; +150.061%]
  • 🟩 throughput [+61123459.094op/s; +61423998.696op/s] or [+44.514%; +44.733%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore net6.0

  • 🟥 execution_time [+423.222ms; +427.956ms] or [+526.352%; +532.239%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore netcoreapp3.1

  • 🟥 execution_time [+299.109ms; +300.180ms] or [+149.189%; +149.723%]

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

  • 🟩 throughput [+95506.123op/s; +104716.950op/s] or [+8.917%; +9.777%]

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

  • 🟩 throughput [+71015.187op/s; +101336.412op/s] or [+5.497%; +7.844%]

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

  • 🟩 throughput [+66682.105op/s; +76004.874op/s] or [+6.623%; +7.549%]

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

  • 🟩 throughput [+44684.321op/s; +51463.151op/s] or [+8.114%; +9.345%]

scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin net6.0

  • 🟩 throughput [+52070.284op/s; +70895.292op/s] or [+5.818%; +7.921%]

Known flaky benchmarks without significant changes:

  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_AddEvent_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_AddEvent_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_AddEvent_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_GetContext_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_GetContext_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_GetContext_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetAttributes_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetAttributes_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetAttributes_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetStatus_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetStatus_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetStatus_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_UpdateName_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_UpdateName_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_UpdateName_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_AddEvent_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_AddEvent_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_AddEvent_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_GetContext_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_GetContext_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_GetContext_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_RecordException_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_RecordException_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_RecordException_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetAttributes_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetAttributes_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetAttributes_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetStatus_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetStatus_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetStatus_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_UpdateName_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_UpdateName_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_UpdateName_Sampled netcoreapp3.1
  • scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild net6.0
  • scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice net6.0
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice netcoreapp3.1
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool net6.0
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool netcoreapp3.1
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice netcoreapp3.1
  • scenario:Benchmarks.Trace.ILoggerBenchmark.EnrichedLog net472
  • scenario:Benchmarks.Trace.ILoggerBenchmark.EnrichedLog netcoreapp3.1
  • scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark net472
  • scenario:Benchmarks.Trace.RedisBenchmark.SendReceive net472
  • scenario:Benchmarks.Trace.RedisBenchmark.SendReceive netcoreapp3.1
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope net472
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope netcoreapp3.1
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishSpan net472
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishTwoScopes net472
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishTwoScopes netcoreapp3.1
  • scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin net472
  • scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin netcoreapp3.1

@gleocadie
gleocadie marked this pull request as ready for review August 13, 2026 10:59
@gleocadie
gleocadie requested a review from a team as a code owner August 13, 2026 10:59

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 38af141644

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@gleocadie
gleocadie requested a review from a team as a code owner August 13, 2026 11:24
StartServices() can never run more than once per process: it's called
either from Initialize() (ManuallyEnabled, itself a one-time CLR
callback) or from OnStartDelayedProfiling(), which SsiManager's
StartProfiling() wraps in std::call_once. A service that fails Start()
is not retried within the same process - the profiler is simply not
started, and a subsequent attempt only happens in a fresh process.

So the "clean up a leftover thread from a previous timed-out attempt
before reassigning _pWatcherThread" guard added for the earlier codex
comment was defending against a retry that cannot happen here. Removed,
along with the comments justifying it on that now-known-incorrect
premise. The other half of that fix stays: requesting shutdown on
timeout so the thread doesn't run unsupervised, since that's needed
regardless of retries - StopServices()'s error-cleanup path (triggered
by some *other* service failing in the same StartServices() pass) hits
the same Stop()-CAS-guard-skips-StopImpl() gap without any retry
involved.

Verified: full native test suite passes (579/580, 1 pre-existing
unrelated skip).

@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 except a few over-commented code

Comment thread profiler/src/ProfilerEngine/Datadog.Profiler.Native/CorProfilerCallback.cpp Outdated
Comment thread profiler/src/ProfilerEngine/Datadog.Profiler.Native/StackSamplerLoopManager.cpp Outdated
Comment thread profiler/src/ProfilerEngine/Datadog.Profiler.Native/StackSamplerLoopManager.cpp Outdated
Comment thread profiler/src/ProfilerEngine/Datadog.Profiler.Native/StackSamplerLoopManager.cpp Outdated
Comment thread profiler/src/ProfilerEngine/Datadog.Profiler.Native/StackSamplerLoopManager.cpp Outdated
Comment thread profiler/src/ProfilerEngine/Datadog.Profiler.Native/StackSamplerLoopManager.cpp Outdated
Comment thread profiler/src/ProfilerEngine/Datadog.Profiler.Native/StackSamplerLoopManager.h Outdated
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 identified-by:crashtracking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants