From 0eeaa1daf79eb2b1aab3d7dc682e9381f977af26 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Sun, 24 Mar 2024 20:44:44 +0100 Subject: [PATCH 1/7] wip: task based profiling --- src/Sentry.Profiling/SampleProfileBuilder.cs | 6 ++++- src/Sentry.Profiling/SampleProfilerSession.cs | 10 ++++++++- .../SamplingTransactionProfiler.cs | 3 +-- .../TraceLogProcessorTests.verify.cs | 22 +++++++++---------- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/Sentry.Profiling/SampleProfileBuilder.cs b/src/Sentry.Profiling/SampleProfileBuilder.cs index bdef768d85..b6e752ee92 100644 --- a/src/Sentry.Profiling/SampleProfileBuilder.cs +++ b/src/Sentry.Profiling/SampleProfileBuilder.cs @@ -12,6 +12,7 @@ internal class SampleProfileBuilder { private readonly SentryOptions _options; private readonly TraceLog _traceLog; + private readonly ActivityComputer _activityComputer; // Output profile being built. public readonly SampleProfile Profile = new(); @@ -28,10 +29,11 @@ internal class SampleProfileBuilder // TODO make downsampling conditional once this is available: https://github.com/dotnet/runtime/issues/82939 private readonly Downsampler _downsampler = new(); - public SampleProfileBuilder(SentryOptions options, TraceLog traceLog) + public SampleProfileBuilder(SentryOptions options, TraceLog traceLog, ActivityComputer activityComputer) { _options = options; _traceLog = traceLog; + _activityComputer = activityComputer; } internal void AddSample(TraceEvent data, double timestampMs) @@ -50,6 +52,7 @@ internal void AddSample(TraceEvent data, double timestampMs) return; } + var activity = _activityComputer.GetCurrentActivity(thread); // XXX var threadIndex = AddThread(thread); if (threadIndex < 0) { @@ -57,6 +60,7 @@ internal void AddSample(TraceEvent data, double timestampMs) return; } + // We need custom sampling because the TraceLog dispatches events from a queue with a delay of about 2 seconds. if (!_downsampler.ShouldSample(threadIndex, timestampMs)) { return; diff --git a/src/Sentry.Profiling/SampleProfilerSession.cs b/src/Sentry.Profiling/SampleProfilerSession.cs index 1ae7b24171..92edbe7adc 100644 --- a/src/Sentry.Profiling/SampleProfilerSession.cs +++ b/src/Sentry.Profiling/SampleProfilerSession.cs @@ -1,5 +1,6 @@ using System.Diagnostics.Tracing; using Microsoft.Diagnostics.NETCore.Client; +using Microsoft.Diagnostics.Symbols; using Microsoft.Diagnostics.Tracing; using Microsoft.Diagnostics.Tracing.Etlx; using Microsoft.Diagnostics.Tracing.EventPipe; @@ -14,6 +15,8 @@ internal class SampleProfilerSession : IDisposable private readonly EventPipeSession _session; private readonly TraceLogEventSource _eventSource; private readonly SampleProfilerTraceEventParser _sampleEventParser; + private readonly SymbolReader _symboReader; + private readonly ActivityComputer _activityComputer; private readonly IDiagnosticLogger? _logger; private readonly SentryStopwatch _stopwatch; private bool _stopped = false; @@ -24,6 +27,8 @@ private SampleProfilerSession(SentryStopwatch stopwatch, EventPipeSession sessio _logger = logger; _eventSource = eventSource; _sampleEventParser = new SampleProfilerTraceEventParser(_eventSource); + _symboReader = new SymbolReader(TextWriter.Null); + _activityComputer = new ActivityComputer(eventSource, _symboReader); _stopwatch = stopwatch; } @@ -38,7 +43,7 @@ private SampleProfilerSession(SentryStopwatch stopwatch, EventPipeSession sessio // | ThreadTransfer | GCHeapAndTypeNames | Codesymbols | Compilation, new EventPipeProvider(ClrTraceEventParser.ProviderName, EventLevel.Informational, (long) ClrTraceEventParser.Keywords.Default), new EventPipeProvider(SampleProfilerTraceEventParser.ProviderName, EventLevel.Informational), - // new EventPipeProvider(TplEtwProviderTraceEventParser.ProviderName, EventLevel.Informational, (long) TplEtwProviderTraceEventParser.Keywords.Default) + new EventPipeProvider(TplEtwProviderTraceEventParser.ProviderName, EventLevel.Informational, (long) TplEtwProviderTraceEventParser.Keywords.Default) }; // Exposed only for benchmarks. @@ -47,6 +52,8 @@ private SampleProfilerSession(SentryStopwatch stopwatch, EventPipeSession sessio public SampleProfilerTraceEventParser SampleEventParser => _sampleEventParser; + public ActivityComputer ActivityComputer => _activityComputer; + public TimeSpan Elapsed => _stopwatch.Elapsed; public TraceLog TraceLog => _eventSource.TraceLog; @@ -128,6 +135,7 @@ public void Stop() _stopped = true; _session.Stop(); _session.Dispose(); + _symboReader.Dispose(); _eventSource.Dispose(); } catch (Exception ex) diff --git a/src/Sentry.Profiling/SamplingTransactionProfiler.cs b/src/Sentry.Profiling/SamplingTransactionProfiler.cs index 52d6ea193b..df6fb8c8ba 100644 --- a/src/Sentry.Profiling/SamplingTransactionProfiler.cs +++ b/src/Sentry.Profiling/SamplingTransactionProfiler.cs @@ -24,7 +24,7 @@ public SamplingTransactionProfiler(SentryOptions options, SampleProfilerSession _cancellationToken = cancellationToken; _startTimeMs = session.Elapsed.TotalMilliseconds; _endTimeMs = double.MaxValue; - _processor = new SampleProfileBuilder(options, session.TraceLog); + _processor = new SampleProfileBuilder(options, session.TraceLog, session.ActivityComputer); session.SampleEventParser.ThreadSample += OnThreadSample; cancellationToken.Register(() => { @@ -61,7 +61,6 @@ private bool Stop(double? endTimeMs = null) return false; } - // We need custom sampling because the TraceLog dispatches events from a queue with a delay of about 2 seconds. private void OnThreadSample(TraceEvent data) { var timestampMs = data.TimeStampRelativeMSec; diff --git a/test/Sentry.Profiling.Tests/TraceLogProcessorTests.verify.cs b/test/Sentry.Profiling.Tests/TraceLogProcessorTests.verify.cs index 9829fa30e1..ce12c6b3a1 100644 --- a/test/Sentry.Profiling.Tests/TraceLogProcessorTests.verify.cs +++ b/test/Sentry.Profiling.Tests/TraceLogProcessorTests.verify.cs @@ -1,3 +1,4 @@ +using Microsoft.Diagnostics.Symbols; using Microsoft.Diagnostics.Tracing; using Microsoft.Diagnostics.Tracing.Etlx; using Microsoft.Diagnostics.Tracing.EventPipe; @@ -33,17 +34,6 @@ public TraceLogProcessorTests(ITestOutputHelper output) // var json = profile.ToJsonString(_testOutputLogger); // } - private SampleProfile BuilProfile(TraceLogEventSource eventSource) - { - var builder = new SampleProfileBuilder(new() { DiagnosticLogger = _testOutputLogger }, eventSource.TraceLog); - new SampleProfilerTraceEventParser(eventSource).ThreadSample += delegate (ClrThreadSampleTraceData data) - { - builder.AddSample(data, data.TimeStampRelativeMSec); - }; - eventSource.Process(); - return builder.Profile; - } - private SampleProfile GetProfile() { var etlxFilePath = Path.Combine(_resourcesPath, "sample.etlx"); @@ -62,7 +52,15 @@ private SampleProfile GetProfile() using var traceLog = new TraceLog(etlxFilePath); using var eventSource = traceLog.Events.GetSource(); - return BuilProfile(eventSource); + using var symboReader = new SymbolReader(TextWriter.Null); + var activityComputer = new ActivityComputer(eventSource, symboReader); + var builder = new SampleProfileBuilder(new() { DiagnosticLogger = _testOutputLogger }, eventSource.TraceLog, activityComputer); + new SampleProfilerTraceEventParser(eventSource).ThreadSample += (ClrThreadSampleTraceData data) => + { + builder.AddSample(data, data.TimeStampRelativeMSec); + }; + eventSource.Process(); + return builder.Profile; } [Fact] From 7cdd1443b5423275eb91ad19f0b39f86e7596e3c Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Mon, 25 Mar 2024 10:12:53 +0100 Subject: [PATCH 2/7] add activities as threads --- src/Sentry.Profiling/SampleProfileBuilder.cs | 63 ++++++++++++++++---- 1 file changed, 51 insertions(+), 12 deletions(-) diff --git a/src/Sentry.Profiling/SampleProfileBuilder.cs b/src/Sentry.Profiling/SampleProfileBuilder.cs index b6e752ee92..9448432cb5 100644 --- a/src/Sentry.Profiling/SampleProfileBuilder.cs +++ b/src/Sentry.Profiling/SampleProfileBuilder.cs @@ -26,6 +26,9 @@ internal class SampleProfileBuilder // A sparse array mapping from a ThreadIndex to an index in Profile.Threads. private readonly Dictionary _threadIndexes = new(); + // A sparse array mapping from an ActivityIndex to an index in Profile.Threads. + private readonly Dictionary _activityIndexes = new(); + // TODO make downsampling conditional once this is available: https://github.com/dotnet/runtime/issues/82939 private readonly Downsampler _downsampler = new(); @@ -52,8 +55,23 @@ internal void AddSample(TraceEvent data, double timestampMs) return; } - var activity = _activityComputer.GetCurrentActivity(thread); // XXX - var threadIndex = AddThread(thread); + var activity = _activityComputer.GetCurrentActivity(thread); + if (activity is null) + { + _options.DiagnosticLogger?.LogDebug("Failed to get activity for a profiler sample. Skipping."); + return; + } + + var threadIndex = -1; + if (activity.IsThreadActivity) + { + threadIndex = AddThread(thread); + } + else + { + threadIndex = AddActivity(activity); + } + if (threadIndex < 0) { _options.DiagnosticLogger?.LogDebug("Profiler Sample threadIndex is invalid. Skipping."); @@ -138,24 +156,45 @@ private int AddStackFrame(CodeAddressIndex codeAddressIndex) } /// - /// Check if the thread is already stored in the output Profile, or adds it. + /// Ensures the thread is stored in the output Profile. /// - /// The index to the output Profile frames array. + /// The index to the output Profile thread array. private int AddThread(TraceThread thread) { var key = (int)thread.ThreadIndex; - if (!_threadIndexes.ContainsKey(key)) + if (!_threadIndexes.TryGetValue(key, out var value)) { - Profile.Threads.Add(new() - { - Name = thread.ThreadInfo ?? $"Thread {thread.ThreadID}", - }); - _threadIndexes[key] = Profile.Threads.Count - 1; - _downsampler.NewThreadAdded(_threadIndexes[key]); + value = AddSampleProfileThread(thread.ThreadInfo ?? $"Thread {thread.ThreadID}"); + _threadIndexes[key] = value; } - return _threadIndexes[key]; + return value; + } + + /// + /// Ensures the activity is stored in the output Profile as a Thread. + /// + /// The index to the output Profile thread array. + private int AddActivity(TraceActivity activity) + { + var key = (int)activity.Index; + + if (!_activityIndexes.TryGetValue(key, out var value)) + { + value = AddSampleProfileThread(activity.Name ?? $"Activity {activity.Path}"); + _activityIndexes[key] = value; + } + + return value; + } + + private int AddSampleProfileThread(string name) + { + Profile.Threads.Add(new() { Name = name }); + var value = Profile.Threads.Count - 1; + _downsampler.NewThreadAdded(value); + return value; } private SentryStackFrame CreateStackFrame(CodeAddressIndex codeAddressIndex) From eb65f1254ed2aba53321ed3213ea049a1cf7f4db Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Mon, 25 Mar 2024 16:48:23 +0100 Subject: [PATCH 3/7] activity-aware stack traces --- src/Sentry.Profiling/SampleProfileBuilder.cs | 129 ++++++++++++++---- src/Sentry.Profiling/SampleProfilerSession.cs | 13 +- .../SamplingTransactionProfiler.cs | 2 +- .../TraceLogProcessorTests.verify.cs | 8 +- 4 files changed, 121 insertions(+), 31 deletions(-) diff --git a/src/Sentry.Profiling/SampleProfileBuilder.cs b/src/Sentry.Profiling/SampleProfileBuilder.cs index 9448432cb5..c7ee985f94 100644 --- a/src/Sentry.Profiling/SampleProfileBuilder.cs +++ b/src/Sentry.Profiling/SampleProfileBuilder.cs @@ -1,5 +1,6 @@ using Microsoft.Diagnostics.Tracing; using Microsoft.Diagnostics.Tracing.Etlx; +using Microsoft.Diagnostics.Tracing.Stacks; using Sentry.Extensibility; using Sentry.Protocol; @@ -13,6 +14,8 @@ internal class SampleProfileBuilder private readonly SentryOptions _options; private readonly TraceLog _traceLog; private readonly ActivityComputer _activityComputer; + // private readonly StartStopActivityComputer _startStopActivityComputer; + private readonly MutableTraceEventStackSource _stackSource; // Output profile being built. public readonly SampleProfile Profile = new(); @@ -23,6 +26,9 @@ internal class SampleProfileBuilder // A dictionary from a CallStackIndex to an index in the output Profile.stacks. private readonly Dictionary _stackIndexes = new(); + // A dictionary from a StackSourceCallStackIndex to an index in the output Profile.stacks. + private readonly Dictionary _stackSourceStackIndexes = new(); + // A sparse array mapping from a ThreadIndex to an index in Profile.Threads. private readonly Dictionary _threadIndexes = new(); @@ -32,11 +38,16 @@ internal class SampleProfileBuilder // TODO make downsampling conditional once this is available: https://github.com/dotnet/runtime/issues/82939 private readonly Downsampler _downsampler = new(); - public SampleProfileBuilder(SentryOptions options, TraceLog traceLog, ActivityComputer activityComputer) + public SampleProfileBuilder( + SentryOptions options, + TraceLog traceLog, + MutableTraceEventStackSource stackSource, + ActivityComputer activityComputer) { _options = options; _traceLog = traceLog; _activityComputer = activityComputer; + _stackSource = stackSource; } internal void AddSample(TraceEvent data, double timestampMs) @@ -48,13 +59,6 @@ internal void AddSample(TraceEvent data, double timestampMs) return; } - var callStackIndex = data.CallStackIndex(); - if (callStackIndex == CallStackIndex.Invalid) - { - _options.DiagnosticLogger?.LogDebug("Encountered a Profiler Sample without an associated call stack. Skipping."); - return; - } - var activity = _activityComputer.GetCurrentActivity(thread); if (activity is null) { @@ -62,7 +66,7 @@ internal void AddSample(TraceEvent data, double timestampMs) return; } - var threadIndex = -1; + int threadIndex; if (activity.IsThreadActivity) { threadIndex = AddThread(thread); @@ -84,10 +88,19 @@ internal void AddSample(TraceEvent data, double timestampMs) return; } - var stackIndex = AddStackTrace(callStackIndex); + int stackIndex; + if (activity.IsThreadActivity) + { + stackIndex = AddThreadStackTrace(data); + } + else + { + stackIndex = AddActivityStackTrace(thread, data); + } + if (stackIndex < 0) { - _options.DiagnosticLogger?.LogDebug("Invalid stackIndex for Profiler Sample. Skipping."); + _options.DiagnosticLogger?.LogDebug("Encountered a Profiler Sample without an associated call stack. Skipping."); return; } @@ -103,17 +116,50 @@ internal void AddSample(TraceEvent data, double timestampMs) /// Adds stack trace and frames, if missing. /// /// The index into the Profile's stacks list - private int AddStackTrace(CallStackIndex callstackIndex) + private int AddThreadStackTrace(TraceEvent data) { - var key = (int)callstackIndex; + var callStackIndex = data.CallStackIndex(); + if (callStackIndex == CallStackIndex.Invalid) + { + return -1; + } - if (!_stackIndexes.ContainsKey(key)) + var key = (int)callStackIndex; + if (!_stackIndexes.TryGetValue(key, out var value)) + { + Profile.Stacks.Add(CreateStackTrace(callStackIndex)); + value = Profile.Stacks.Count - 1; + _stackIndexes[key] = value; + } + return value; + } + + /// + /// Adds stack trace and frames, if missing. + /// + /// The index into the Profile's stacks list + private int AddActivityStackTrace(TraceThread thread, TraceEvent data) + { + var stackSourceCallStackIndex = StackSourceCallStackIndex.Invalid; + lock (_stackSource) { - Profile.Stacks.Add(CreateStackTrace(callstackIndex)); - _stackIndexes[key] = Profile.Stacks.Count - 1; + stackSourceCallStackIndex = _activityComputer.GetCallStack(_stackSource, data, + null // TODO topThread => _startStopActivityComputer.GetCurrentStartStopActivityStack(_stackSource, thread, topThread) + ); + } + if (stackSourceCallStackIndex == StackSourceCallStackIndex.Invalid) + { + return -1; } - return _stackIndexes[key]; + var key = (int)stackSourceCallStackIndex; + if (!_stackSourceStackIndexes.TryGetValue(key, out var value)) + { + Profile.Stacks.Add(CreateStackTrace(stackSourceCallStackIndex)); + value = Profile.Stacks.Count - 1; + _stackIndexes[key] = value; + } + return value; } private Internal.GrowableArray CreateStackTrace(CallStackIndex callstackIndex) @@ -122,16 +168,42 @@ private Internal.GrowableArray CreateStackTrace(CallStackIndex callstackInd while (callstackIndex != CallStackIndex.Invalid) { var codeAddressIndex = _traceLog.CallStacks.CodeAddressIndex(callstackIndex); - if (codeAddressIndex != CodeAddressIndex.Invalid) - { - stackTrace.Add(AddStackFrame(codeAddressIndex)); - callstackIndex = _traceLog.CallStacks.Caller(callstackIndex); - } - else + if (codeAddressIndex == CodeAddressIndex.Invalid) { // No need to traverse further up the stack when we're on the thread/process. break; } + + stackTrace.Add(AddStackFrame(codeAddressIndex)); + callstackIndex = _traceLog.CallStacks.Caller(callstackIndex); + } + + stackTrace.Trim(10); + return stackTrace; + } + + private Internal.GrowableArray CreateStackTrace(StackSourceCallStackIndex callstackIndex) + { + var stackTrace = new Internal.GrowableArray(10); + CodeAddressIndex codeAddressIndex; + while (callstackIndex != StackSourceCallStackIndex.Invalid + // GetFrameIndex() throws... seems to be happening on top thread frames for some reason... + && (callstackIndex - _stackSource.Interner.CallStackStartIndex) < _stackSource.Interner.CallStackCount) + { + lock (_stackSource) + { + var frameIndex = _stackSource.GetFrameIndex(callstackIndex); + codeAddressIndex = _stackSource.GetFrameCodeAddress(frameIndex); + if (codeAddressIndex == CodeAddressIndex.Invalid) + { + // No need to traverse further up the stack when we're on the thread/process. + break; + } + + callstackIndex = _stackSource.GetCallerIndex(callstackIndex); + } + + stackTrace.Add(AddStackFrame(codeAddressIndex)); } stackTrace.Trim(10); @@ -146,13 +218,14 @@ private int AddStackFrame(CodeAddressIndex codeAddressIndex) { var key = (int)codeAddressIndex; - if (!_frameIndexes.ContainsKey(key)) + if (!_frameIndexes.TryGetValue(key, out var value)) { Profile.Frames.Add(CreateStackFrame(codeAddressIndex)); - _frameIndexes[key] = Profile.Frames.Count - 1; + value = Profile.Frames.Count - 1; + _frameIndexes[key] = value; } - return _frameIndexes[key]; + return value; } /// @@ -182,7 +255,9 @@ private int AddActivity(TraceActivity activity) if (!_activityIndexes.TryGetValue(key, out var value)) { - value = AddSampleProfileThread(activity.Name ?? $"Activity {activity.Path}"); + // Note: there's also activity.Name but it's rather verbose: + // '' + value = AddSampleProfileThread($"Activity {activity.Path}"); _activityIndexes[key] = value; } diff --git a/src/Sentry.Profiling/SampleProfilerSession.cs b/src/Sentry.Profiling/SampleProfilerSession.cs index 92edbe7adc..cda158fffd 100644 --- a/src/Sentry.Profiling/SampleProfilerSession.cs +++ b/src/Sentry.Profiling/SampleProfilerSession.cs @@ -5,6 +5,7 @@ using Microsoft.Diagnostics.Tracing.Etlx; using Microsoft.Diagnostics.Tracing.EventPipe; using Microsoft.Diagnostics.Tracing.Parsers; +using Microsoft.Diagnostics.Tracing.Stacks; using Sentry.Extensibility; using Sentry.Internal; @@ -14,9 +15,11 @@ internal class SampleProfilerSession : IDisposable { private readonly EventPipeSession _session; private readonly TraceLogEventSource _eventSource; + private readonly MutableTraceEventStackSource _stackSource; private readonly SampleProfilerTraceEventParser _sampleEventParser; private readonly SymbolReader _symboReader; private readonly ActivityComputer _activityComputer; + // private readonly StartStopActivityComputer _startStopActivityComputer; private readonly IDiagnosticLogger? _logger; private readonly SentryStopwatch _stopwatch; private bool _stopped = false; @@ -29,7 +32,12 @@ private SampleProfilerSession(SentryStopwatch stopwatch, EventPipeSession sessio _sampleEventParser = new SampleProfilerTraceEventParser(_eventSource); _symboReader = new SymbolReader(TextWriter.Null); _activityComputer = new ActivityComputer(eventSource, _symboReader); + // _startStopActivityComputer = new StartStopActivityComputer(eventSource, _activityComputer); _stopwatch = stopwatch; + _stackSource = new MutableTraceEventStackSource(eventSource.TraceLog) + { + OnlyManagedCodeStacks = true // EventPipe only has managed stacks. + }; } // Exposed only for benchmarks. @@ -52,8 +60,6 @@ private SampleProfilerSession(SentryStopwatch stopwatch, EventPipeSession sessio public SampleProfilerTraceEventParser SampleEventParser => _sampleEventParser; - public ActivityComputer ActivityComputer => _activityComputer; - public TimeSpan Elapsed => _stopwatch.Elapsed; public TraceLog TraceLog => _eventSource.TraceLog; @@ -146,4 +152,7 @@ public void Stop() } public void Dispose() => Stop(); + + public SampleProfileBuilder CreateProfileBuilder(SentryOptions options) + => new(options, _eventSource.TraceLog, _stackSource, _activityComputer); } diff --git a/src/Sentry.Profiling/SamplingTransactionProfiler.cs b/src/Sentry.Profiling/SamplingTransactionProfiler.cs index df6fb8c8ba..878b23f73b 100644 --- a/src/Sentry.Profiling/SamplingTransactionProfiler.cs +++ b/src/Sentry.Profiling/SamplingTransactionProfiler.cs @@ -24,7 +24,7 @@ public SamplingTransactionProfiler(SentryOptions options, SampleProfilerSession _cancellationToken = cancellationToken; _startTimeMs = session.Elapsed.TotalMilliseconds; _endTimeMs = double.MaxValue; - _processor = new SampleProfileBuilder(options, session.TraceLog, session.ActivityComputer); + _processor = session.CreateProfileBuilder(options); session.SampleEventParser.ThreadSample += OnThreadSample; cancellationToken.Register(() => { diff --git a/test/Sentry.Profiling.Tests/TraceLogProcessorTests.verify.cs b/test/Sentry.Profiling.Tests/TraceLogProcessorTests.verify.cs index ce12c6b3a1..4cf3d318e5 100644 --- a/test/Sentry.Profiling.Tests/TraceLogProcessorTests.verify.cs +++ b/test/Sentry.Profiling.Tests/TraceLogProcessorTests.verify.cs @@ -2,6 +2,7 @@ using Microsoft.Diagnostics.Tracing; using Microsoft.Diagnostics.Tracing.Etlx; using Microsoft.Diagnostics.Tracing.EventPipe; +using Microsoft.Diagnostics.Tracing.Stacks; namespace Sentry.Profiling.Tests; @@ -53,8 +54,13 @@ private SampleProfile GetProfile() using var traceLog = new TraceLog(etlxFilePath); using var eventSource = traceLog.Events.GetSource(); using var symboReader = new SymbolReader(TextWriter.Null); + var options = new SentryOptions() { DiagnosticLogger = _testOutputLogger }; var activityComputer = new ActivityComputer(eventSource, symboReader); - var builder = new SampleProfileBuilder(new() { DiagnosticLogger = _testOutputLogger }, eventSource.TraceLog, activityComputer); + var stackSource = new MutableTraceEventStackSource(eventSource.TraceLog) + { + OnlyManagedCodeStacks = true + }; + var builder = new SampleProfileBuilder(options, traceLog, stackSource, activityComputer); new SampleProfilerTraceEventParser(eventSource).ThreadSample += (ClrThreadSampleTraceData data) => { builder.AddSample(data, data.TimeStampRelativeMSec); From a5dedeca9faa5a5897a1dc7a08f1a541f7722a7c Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Mon, 25 Mar 2024 17:09:42 +0100 Subject: [PATCH 4/7] update profiling example --- .../Program.cs | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/samples/Sentry.Samples.Console.Profiling/Program.cs b/samples/Sentry.Samples.Console.Profiling/Program.cs index ef94176029..cc2d7f90c4 100644 --- a/samples/Sentry.Samples.Console.Profiling/Program.cs +++ b/samples/Sentry.Samples.Console.Profiling/Program.cs @@ -3,7 +3,7 @@ internal static class Program { - private static void Main() + private static async Task Main() { // Enable the SDK using (SentrySdk.Init(options => @@ -12,7 +12,7 @@ private static void Main() // NOTE: ADD YOUR OWN DSN BELOW so you can see the events in your own Sentry account "https://eb18e953812b41c3aeb042e666fd3b5c@o447951.ingest.sentry.io/5428537"; - options.Debug = true; + options.Debug = false; // options.AutoSessionTracking = true; options.IsGlobalModeEnabled = true; options.TracesSampleRate = 1.0; @@ -26,32 +26,26 @@ private static void Main() options.AddIntegration(new ProfilingIntegration(TimeSpan.FromMilliseconds(500))); })) { - var tx = SentrySdk.StartTransaction("app", "run"); var count = 10; + + var sw = Stopwatch.StartNew(); + var tx = SentrySdk.StartTransaction("FindPrimeNumber", "Sequential"); for (var i = 0; i < count; i++) { FindPrimeNumber(100000); } - tx.Finish(); - var sw = Stopwatch.StartNew(); - - // Flushing takes 10 seconds consistently? + Console.WriteLine("Sequential computation finished in " + sw.Elapsed); SentrySdk.Flush(TimeSpan.FromMinutes(5)); Console.WriteLine("Flushed in " + sw.Elapsed); + Thread.Sleep(500); - // is the second profile faster? - tx = SentrySdk.StartTransaction("app", "run"); - count = 10; - for (var i = 0; i < count; i++) - { - FindPrimeNumber(100000); - } - + sw.Restart(); + tx = SentrySdk.StartTransaction("FindPrimeNumber", "Parallel"); + var tasks = Enumerable.Range(1, count).ToList().Select(_ => Task.Run(() => FindPrimeNumber(100000))); + await Task.WhenAll(tasks).ConfigureAwait(false); tx.Finish(); - sw = Stopwatch.StartNew(); - - // Flushing takes 10 seconds consistently? + Console.WriteLine("Parallel computation finished in " + sw.Elapsed); SentrySdk.Flush(TimeSpan.FromMinutes(5)); Console.WriteLine("Flushed in " + sw.Elapsed); } // On Dispose: SDK closed, events queued are flushed/sent to Sentry From 42ab2d56e934d75b23ae1634cf7215267274065d Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Mon, 25 Mar 2024 20:02:57 +0100 Subject: [PATCH 5/7] update profiling sample --- samples/Sentry.Samples.Console.Profiling/Program.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/samples/Sentry.Samples.Console.Profiling/Program.cs b/samples/Sentry.Samples.Console.Profiling/Program.cs index cc2d7f90c4..e93526d81b 100644 --- a/samples/Sentry.Samples.Console.Profiling/Program.cs +++ b/samples/Sentry.Samples.Console.Profiling/Program.cs @@ -38,11 +38,16 @@ private static async Task Main() Console.WriteLine("Sequential computation finished in " + sw.Elapsed); SentrySdk.Flush(TimeSpan.FromMinutes(5)); Console.WriteLine("Flushed in " + sw.Elapsed); - Thread.Sleep(500); + await Task.Delay(500); sw.Restart(); tx = SentrySdk.StartTransaction("FindPrimeNumber", "Parallel"); - var tasks = Enumerable.Range(1, count).ToList().Select(_ => Task.Run(() => FindPrimeNumber(100000))); + var tasks = Enumerable.Range(1, count).ToList().Select(_ => Task.Run(async () => + { + FindPrimeNumber(100000); + await Task.Delay(500); + FindPrimeNumber(100000); + })); await Task.WhenAll(tasks).ConfigureAwait(false); tx.Finish(); Console.WriteLine("Parallel computation finished in " + sw.Elapsed); From 619942bc65f0e9139cd1ae97dc9f0657f2d1faf0 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Tue, 28 May 2024 10:20:40 +0200 Subject: [PATCH 6/7] test: update expected test files --- ...ofileInfo_Serialization_Works.verified.txt | 415 ++++++++++-------- ...s.Profile_Serialization_Works.verified.txt | 415 ++++++++++-------- 2 files changed, 474 insertions(+), 356 deletions(-) diff --git a/test/Sentry.Profiling.Tests/TraceLogProcessorTests.ProfileInfo_Serialization_Works.verified.txt b/test/Sentry.Profiling.Tests/TraceLogProcessorTests.ProfileInfo_Serialization_Works.verified.txt index 714859c86d..0e3ee5f44e 100644 --- a/test/Sentry.Profiling.Tests/TraceLogProcessorTests.ProfileInfo_Serialization_Works.verified.txt +++ b/test/Sentry.Profiling.Tests/TraceLogProcessorTests.ProfileInfo_Serialization_Works.verified.txt @@ -42,7 +42,19 @@ name: Thread 7860 }, 6: { + name: Activity //14/18 + }, + 7: { + name: Activity //14/18/24/28/32 + }, + 8: { + name: Activity //2/23 + }, + 9: { name: Thread 12688 + }, + 10: { + name: Activity //2/23/39 } }, stacks: [ @@ -107,95 +119,147 @@ 36 ], [ + 0, + 1, 37 ], + [ + 38 + ], [ 0, 1, - 38, + 37 + ], + [ 39, 40, 41, 42, 43, 44, - 45, - 46, - 22 + 38 + ], + [ + 0, + 1, + 37 ], [ + 0, + 1, + 37 + ], + [ + 45, + 46, 47, 48, 49, + 38 + ], + [ + 0, + 1, + 37 + ], + [ 50, 51, 52, + 53, + 54 + ], + [ + 0, + 1, 37 ], [ - 53, - 54, 55, 56, 57, - 37 - ], - [ 58, 59, 60, 61, - 62 - ], - [ + 62, 63, 64, + 50, + 51, + 52, + 53, + 54 + ], + [ + 0, + 1, + 37 + ], + [ 65, 66, 67, 68, 69, 70, + 50, + 51, + 52, + 53, + 54 + ], + [ + 0, + 1, + 37 + ], + [ 71, 72, - 58, - 59, - 60, - 61, - 62 + 70, + 50, + 51, + 52, + 53, + 54 + ], + [ + 0, + 1, + 37 ], [ 73, + 51, + 52, + 53, + 54 + ], + [ + 0, + 1, + 37 + ], + [ 74, 75, 76, 77, 78, - 58, - 59, - 60, - 61, - 62 - ], - [ 79, 80, - 78, - 58, - 59, - 60, - 61, - 62 + 81, + 82, + 54 ], [ - 81, - 59, - 60, - 61, - 62 + 0, + 1, + 37 ], [ - 82, 83, 84, 85, @@ -204,48 +268,38 @@ 88, 89, 90, - 62 - ], - [ 91, 92, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 54 + ], + [ 93, 94, - 95, + 95 + ], + [ + 18, + 19, + 20, 96, - 97, - 98, - 99, - 100, - 84, - 85, - 86, - 87, - 88, - 89, - 90, - 62 + 22 ], [ 0, 1, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 22 + 37 ], [ - 18, - 19, - 20, - 101, - 22 + 97, + 98, + 99 ] ], frames: [ @@ -433,55 +487,15 @@ module: System.Private.CoreLib.il, in_app: false }, - { - function: Aura.UI.Gallery.NetCore.Program.Main(class System.String[]), - module: Aura.UI.Gallery.NetCore, - in_app: true - }, { function: System.IO.Stream+<>c.b__40_0(class System.Object), module: System.Private.CoreLib.il, in_app: false }, { - function: System.Threading.Tasks.Task`1[System.Int32].InnerInvoke(), - module: System.Private.CoreLib.il, - in_app: false - }, - { - function: System.Threading.Tasks.Task+<>c.<.cctor>b__272_0(class System.Object), - module: System.Private.CoreLib.il, - in_app: false - }, - { - function: System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(class System.Threading.Thread,class System.Threading.ExecutionContext,class System.Threading.ContextCallback,class System.Object), - module: System.Private.CoreLib.il, - in_app: false - }, - { - function: System.Threading.Tasks.Task.ExecuteWithThreadLocal(class System.Threading.Tasks.Task&,class System.Threading.Thread), - module: System.Private.CoreLib.il, - in_app: false - }, - { - function: System.Threading.Tasks.Task.ExecuteEntryUnsafe(class System.Threading.Thread), - module: System.Private.CoreLib.il, - in_app: false - }, - { - function: System.Threading.Tasks.Task.ExecuteFromThreadPool(class System.Threading.Thread), - module: System.Private.CoreLib.il, - in_app: false - }, - { - function: System.Threading.ThreadPoolWorkQueue.Dispatch(), - module: System.Private.CoreLib.il, - in_app: false - }, - { - function: System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart(), - module: System.Private.CoreLib.il, - in_app: false + function: Aura.UI.Gallery.NetCore.Program.Main(class System.String[]), + module: Aura.UI.Gallery.NetCore, + in_app: true }, { function: System.Collections.Concurrent.ConcurrentDictionary`2[System.__Canon,System.IntPtr].TryAddInternal(!0,value class System.Nullable`1,!1,bool,bool,!1&), @@ -751,10 +765,40 @@ module: avalonia.win32, in_app: true }, + { + function: Aura.UI.Gallery.NetCore.Program+<>c__DisplayClass1_0.
b__1(class System.Threading.Tasks.Task), + module: Aura.UI.Gallery.NetCore, + in_app: true + }, + { + function: System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke(), + module: System.Private.CoreLib.il, + in_app: false + }, + { + function: System.Threading.Tasks.Task+<>c.<.cctor>b__272_0(class System.Object), + module: System.Private.CoreLib.il, + in_app: false + }, { function: System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart(), module: System.Private.CoreLib.il, in_app: false + }, + { + function: System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[System.__Canon,Microsoft.Diagnostics.NETCore.Client.IpcEndpointHelper+d__1].MoveNext(), + module: System.Private.CoreLib.il, + in_app: false + }, + { + function: System.Runtime.CompilerServices.TaskAwaiter+<>c.b__12_0(class System.Action,class System.Threading.Tasks.Task), + module: System.Private.CoreLib.il, + in_app: false + }, + { + function: System.Runtime.CompilerServices.AsyncMethodBuilderCore+ContinuationWrapper.Invoke(), + module: System.Private.CoreLib.il, + in_app: false } ], samples: [ @@ -789,13 +833,13 @@ stack_id: 5 }, { - elapsed_since_start_ns: 11253400, - thread_id: 0, + elapsed_since_start_ns: 9261600, + thread_id: 6, stack_id: 6 }, { - elapsed_since_start_ns: 11260100, - thread_id: 1, + elapsed_since_start_ns: 11253400, + thread_id: 0, stack_id: 7 }, { @@ -814,14 +858,14 @@ stack_id: 4 }, { - elapsed_since_start_ns: 21259900, - thread_id: 0, + elapsed_since_start_ns: 19314800, + thread_id: 6, stack_id: 8 }, { - elapsed_since_start_ns: 21267900, - thread_id: 1, - stack_id: 7 + elapsed_since_start_ns: 21259900, + thread_id: 0, + stack_id: 9 }, { elapsed_since_start_ns: 21270000, @@ -839,13 +883,13 @@ stack_id: 4 }, { - elapsed_since_start_ns: 31243800, - thread_id: 0, - stack_id: 6 + elapsed_since_start_ns: 29316000, + thread_id: 6, + stack_id: 10 }, { - elapsed_since_start_ns: 31248600, - thread_id: 1, + elapsed_since_start_ns: 31243800, + thread_id: 0, stack_id: 7 }, { @@ -864,14 +908,14 @@ stack_id: 4 }, { - elapsed_since_start_ns: 41251400, - thread_id: 0, - stack_id: 9 + elapsed_since_start_ns: 39246300, + thread_id: 6, + stack_id: 11 }, { - elapsed_since_start_ns: 41261500, - thread_id: 1, - stack_id: 7 + elapsed_since_start_ns: 41251400, + thread_id: 0, + stack_id: 12 }, { elapsed_since_start_ns: 41263200, @@ -889,14 +933,14 @@ stack_id: 4 }, { - elapsed_since_start_ns: 51268200, - thread_id: 0, - stack_id: 10 + elapsed_since_start_ns: 49374000, + thread_id: 6, + stack_id: 13 }, { - elapsed_since_start_ns: 51291300, - thread_id: 1, - stack_id: 7 + elapsed_since_start_ns: 51268200, + thread_id: 0, + stack_id: 14 }, { elapsed_since_start_ns: 51294700, @@ -914,14 +958,14 @@ stack_id: 4 }, { - elapsed_since_start_ns: 61258600, - thread_id: 0, - stack_id: 11 + elapsed_since_start_ns: 59327100, + thread_id: 6, + stack_id: 15 }, { - elapsed_since_start_ns: 61269400, - thread_id: 1, - stack_id: 7 + elapsed_since_start_ns: 61258600, + thread_id: 0, + stack_id: 16 }, { elapsed_since_start_ns: 61271800, @@ -939,14 +983,14 @@ stack_id: 4 }, { - elapsed_since_start_ns: 71256100, - thread_id: 0, - stack_id: 12 + elapsed_since_start_ns: 69308800, + thread_id: 6, + stack_id: 17 }, { - elapsed_since_start_ns: 71268300, - thread_id: 1, - stack_id: 7 + elapsed_since_start_ns: 71256100, + thread_id: 0, + stack_id: 18 }, { elapsed_since_start_ns: 71271900, @@ -964,14 +1008,14 @@ stack_id: 4 }, { - elapsed_since_start_ns: 81242100, - thread_id: 0, - stack_id: 13 + elapsed_since_start_ns: 79267700, + thread_id: 6, + stack_id: 19 }, { - elapsed_since_start_ns: 81247700, - thread_id: 1, - stack_id: 7 + elapsed_since_start_ns: 81242100, + thread_id: 0, + stack_id: 20 }, { elapsed_since_start_ns: 81248900, @@ -989,14 +1033,14 @@ stack_id: 4 }, { - elapsed_since_start_ns: 91316900, - thread_id: 0, - stack_id: 14 + elapsed_since_start_ns: 89286500, + thread_id: 6, + stack_id: 21 }, { - elapsed_since_start_ns: 91324700, - thread_id: 1, - stack_id: 7 + elapsed_since_start_ns: 91316900, + thread_id: 0, + stack_id: 22 }, { elapsed_since_start_ns: 91326400, @@ -1014,14 +1058,14 @@ stack_id: 4 }, { - elapsed_since_start_ns: 101264900, - thread_id: 0, - stack_id: 15 + elapsed_since_start_ns: 99267900, + thread_id: 6, + stack_id: 23 }, { - elapsed_since_start_ns: 101272700, - thread_id: 1, - stack_id: 7 + elapsed_since_start_ns: 101264900, + thread_id: 0, + stack_id: 24 }, { elapsed_since_start_ns: 101274300, @@ -1039,15 +1083,20 @@ stack_id: 4 }, { - elapsed_since_start_ns: 112828800, - thread_id: 0, - stack_id: 16 - }, - { - elapsed_since_start_ns: 112839000, + elapsed_since_start_ns: 108788100, thread_id: 1, stack_id: 1 }, + { + elapsed_since_start_ns: 108797900, + thread_id: 7, + stack_id: 25 + }, + { + elapsed_since_start_ns: 112828800, + thread_id: 0, + stack_id: 26 + }, { elapsed_since_start_ns: 112843800, thread_id: 2, @@ -1059,15 +1108,25 @@ stack_id: 3 }, { - elapsed_since_start_ns: 112863500, - thread_id: 4, - stack_id: 17 + elapsed_since_start_ns: 114797500, + thread_id: 8, + stack_id: 27 }, { elapsed_since_start_ns: 114809100, - thread_id: 6, - stack_id: 18 + thread_id: 9, + stack_id: 28 + }, + { + elapsed_since_start_ns: 118824700, + thread_id: 7, + stack_id: 29 + }, + { + elapsed_since_start_ns: 118832200, + thread_id: 10, + stack_id: 30 } ] } -} \ No newline at end of file +} diff --git a/test/Sentry.Profiling.Tests/TraceLogProcessorTests.Profile_Serialization_Works.verified.txt b/test/Sentry.Profiling.Tests/TraceLogProcessorTests.Profile_Serialization_Works.verified.txt index 6eb35f3c22..1127ee1a4f 100644 --- a/test/Sentry.Profiling.Tests/TraceLogProcessorTests.Profile_Serialization_Works.verified.txt +++ b/test/Sentry.Profiling.Tests/TraceLogProcessorTests.Profile_Serialization_Works.verified.txt @@ -19,7 +19,19 @@ name: Thread 7860 }, 6: { + name: Activity //14/18 + }, + 7: { + name: Activity //14/18/24/28/32 + }, + 8: { + name: Activity //2/23 + }, + 9: { name: Thread 12688 + }, + 10: { + name: Activity //2/23/39 } }, stacks: [ @@ -84,95 +96,147 @@ 36 ], [ + 0, + 1, 37 ], + [ + 38 + ], [ 0, 1, - 38, + 37 + ], + [ 39, 40, 41, 42, 43, 44, - 45, - 46, - 22 + 38 + ], + [ + 0, + 1, + 37 ], [ + 0, + 1, + 37 + ], + [ + 45, + 46, 47, 48, 49, + 38 + ], + [ + 0, + 1, + 37 + ], + [ 50, 51, 52, + 53, + 54 + ], + [ + 0, + 1, 37 ], [ - 53, - 54, 55, 56, 57, - 37 - ], - [ 58, 59, 60, 61, - 62 - ], - [ + 62, 63, 64, + 50, + 51, + 52, + 53, + 54 + ], + [ + 0, + 1, + 37 + ], + [ 65, 66, 67, 68, 69, 70, + 50, + 51, + 52, + 53, + 54 + ], + [ + 0, + 1, + 37 + ], + [ 71, 72, - 58, - 59, - 60, - 61, - 62 + 70, + 50, + 51, + 52, + 53, + 54 + ], + [ + 0, + 1, + 37 ], [ 73, + 51, + 52, + 53, + 54 + ], + [ + 0, + 1, + 37 + ], + [ 74, 75, 76, 77, 78, - 58, - 59, - 60, - 61, - 62 - ], - [ 79, 80, - 78, - 58, - 59, - 60, - 61, - 62 + 81, + 82, + 54 ], [ - 81, - 59, - 60, - 61, - 62 + 0, + 1, + 37 ], [ - 82, 83, 84, 85, @@ -181,48 +245,38 @@ 88, 89, 90, - 62 - ], - [ 91, 92, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 54 + ], + [ 93, 94, - 95, + 95 + ], + [ + 18, + 19, + 20, 96, - 97, - 98, - 99, - 100, - 84, - 85, - 86, - 87, - 88, - 89, - 90, - 62 + 22 ], [ 0, 1, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 22 + 37 ], [ - 18, - 19, - 20, - 101, - 22 + 97, + 98, + 99 ] ], frames: [ @@ -410,55 +464,15 @@ module: System.Private.CoreLib.il, in_app: false }, - { - function: Aura.UI.Gallery.NetCore.Program.Main(class System.String[]), - module: Aura.UI.Gallery.NetCore, - in_app: true - }, { function: System.IO.Stream+<>c.b__40_0(class System.Object), module: System.Private.CoreLib.il, in_app: false }, { - function: System.Threading.Tasks.Task`1[System.Int32].InnerInvoke(), - module: System.Private.CoreLib.il, - in_app: false - }, - { - function: System.Threading.Tasks.Task+<>c.<.cctor>b__272_0(class System.Object), - module: System.Private.CoreLib.il, - in_app: false - }, - { - function: System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(class System.Threading.Thread,class System.Threading.ExecutionContext,class System.Threading.ContextCallback,class System.Object), - module: System.Private.CoreLib.il, - in_app: false - }, - { - function: System.Threading.Tasks.Task.ExecuteWithThreadLocal(class System.Threading.Tasks.Task&,class System.Threading.Thread), - module: System.Private.CoreLib.il, - in_app: false - }, - { - function: System.Threading.Tasks.Task.ExecuteEntryUnsafe(class System.Threading.Thread), - module: System.Private.CoreLib.il, - in_app: false - }, - { - function: System.Threading.Tasks.Task.ExecuteFromThreadPool(class System.Threading.Thread), - module: System.Private.CoreLib.il, - in_app: false - }, - { - function: System.Threading.ThreadPoolWorkQueue.Dispatch(), - module: System.Private.CoreLib.il, - in_app: false - }, - { - function: System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart(), - module: System.Private.CoreLib.il, - in_app: false + function: Aura.UI.Gallery.NetCore.Program.Main(class System.String[]), + module: Aura.UI.Gallery.NetCore, + in_app: true }, { function: System.Collections.Concurrent.ConcurrentDictionary`2[System.__Canon,System.IntPtr].TryAddInternal(!0,value class System.Nullable`1,!1,bool,bool,!1&), @@ -728,10 +742,40 @@ module: avalonia.win32, in_app: true }, + { + function: Aura.UI.Gallery.NetCore.Program+<>c__DisplayClass1_0.
b__1(class System.Threading.Tasks.Task), + module: Aura.UI.Gallery.NetCore, + in_app: true + }, + { + function: System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke(), + module: System.Private.CoreLib.il, + in_app: false + }, + { + function: System.Threading.Tasks.Task+<>c.<.cctor>b__272_0(class System.Object), + module: System.Private.CoreLib.il, + in_app: false + }, { function: System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart(), module: System.Private.CoreLib.il, in_app: false + }, + { + function: System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[System.__Canon,Microsoft.Diagnostics.NETCore.Client.IpcEndpointHelper+d__1].MoveNext(), + module: System.Private.CoreLib.il, + in_app: false + }, + { + function: System.Runtime.CompilerServices.TaskAwaiter+<>c.b__12_0(class System.Action,class System.Threading.Tasks.Task), + module: System.Private.CoreLib.il, + in_app: false + }, + { + function: System.Runtime.CompilerServices.AsyncMethodBuilderCore+ContinuationWrapper.Invoke(), + module: System.Private.CoreLib.il, + in_app: false } ], samples: [ @@ -766,13 +810,13 @@ stack_id: 5 }, { - elapsed_since_start_ns: 11253400, - thread_id: 0, + elapsed_since_start_ns: 9261600, + thread_id: 6, stack_id: 6 }, { - elapsed_since_start_ns: 11260100, - thread_id: 1, + elapsed_since_start_ns: 11253400, + thread_id: 0, stack_id: 7 }, { @@ -791,14 +835,14 @@ stack_id: 4 }, { - elapsed_since_start_ns: 21259900, - thread_id: 0, + elapsed_since_start_ns: 19314800, + thread_id: 6, stack_id: 8 }, { - elapsed_since_start_ns: 21267900, - thread_id: 1, - stack_id: 7 + elapsed_since_start_ns: 21259900, + thread_id: 0, + stack_id: 9 }, { elapsed_since_start_ns: 21270000, @@ -816,13 +860,13 @@ stack_id: 4 }, { - elapsed_since_start_ns: 31243800, - thread_id: 0, - stack_id: 6 + elapsed_since_start_ns: 29316000, + thread_id: 6, + stack_id: 10 }, { - elapsed_since_start_ns: 31248600, - thread_id: 1, + elapsed_since_start_ns: 31243800, + thread_id: 0, stack_id: 7 }, { @@ -841,14 +885,14 @@ stack_id: 4 }, { - elapsed_since_start_ns: 41251400, - thread_id: 0, - stack_id: 9 + elapsed_since_start_ns: 39246300, + thread_id: 6, + stack_id: 11 }, { - elapsed_since_start_ns: 41261500, - thread_id: 1, - stack_id: 7 + elapsed_since_start_ns: 41251400, + thread_id: 0, + stack_id: 12 }, { elapsed_since_start_ns: 41263200, @@ -866,14 +910,14 @@ stack_id: 4 }, { - elapsed_since_start_ns: 51268200, - thread_id: 0, - stack_id: 10 + elapsed_since_start_ns: 49374000, + thread_id: 6, + stack_id: 13 }, { - elapsed_since_start_ns: 51291300, - thread_id: 1, - stack_id: 7 + elapsed_since_start_ns: 51268200, + thread_id: 0, + stack_id: 14 }, { elapsed_since_start_ns: 51294700, @@ -891,14 +935,14 @@ stack_id: 4 }, { - elapsed_since_start_ns: 61258600, - thread_id: 0, - stack_id: 11 + elapsed_since_start_ns: 59327100, + thread_id: 6, + stack_id: 15 }, { - elapsed_since_start_ns: 61269400, - thread_id: 1, - stack_id: 7 + elapsed_since_start_ns: 61258600, + thread_id: 0, + stack_id: 16 }, { elapsed_since_start_ns: 61271800, @@ -916,14 +960,14 @@ stack_id: 4 }, { - elapsed_since_start_ns: 71256100, - thread_id: 0, - stack_id: 12 + elapsed_since_start_ns: 69308800, + thread_id: 6, + stack_id: 17 }, { - elapsed_since_start_ns: 71268300, - thread_id: 1, - stack_id: 7 + elapsed_since_start_ns: 71256100, + thread_id: 0, + stack_id: 18 }, { elapsed_since_start_ns: 71271900, @@ -941,14 +985,14 @@ stack_id: 4 }, { - elapsed_since_start_ns: 81242100, - thread_id: 0, - stack_id: 13 + elapsed_since_start_ns: 79267700, + thread_id: 6, + stack_id: 19 }, { - elapsed_since_start_ns: 81247700, - thread_id: 1, - stack_id: 7 + elapsed_since_start_ns: 81242100, + thread_id: 0, + stack_id: 20 }, { elapsed_since_start_ns: 81248900, @@ -966,14 +1010,14 @@ stack_id: 4 }, { - elapsed_since_start_ns: 91316900, - thread_id: 0, - stack_id: 14 + elapsed_since_start_ns: 89286500, + thread_id: 6, + stack_id: 21 }, { - elapsed_since_start_ns: 91324700, - thread_id: 1, - stack_id: 7 + elapsed_since_start_ns: 91316900, + thread_id: 0, + stack_id: 22 }, { elapsed_since_start_ns: 91326400, @@ -991,14 +1035,14 @@ stack_id: 4 }, { - elapsed_since_start_ns: 101264900, - thread_id: 0, - stack_id: 15 + elapsed_since_start_ns: 99267900, + thread_id: 6, + stack_id: 23 }, { - elapsed_since_start_ns: 101272700, - thread_id: 1, - stack_id: 7 + elapsed_since_start_ns: 101264900, + thread_id: 0, + stack_id: 24 }, { elapsed_since_start_ns: 101274300, @@ -1016,15 +1060,20 @@ stack_id: 4 }, { - elapsed_since_start_ns: 112828800, - thread_id: 0, - stack_id: 16 - }, - { - elapsed_since_start_ns: 112839000, + elapsed_since_start_ns: 108788100, thread_id: 1, stack_id: 1 }, + { + elapsed_since_start_ns: 108797900, + thread_id: 7, + stack_id: 25 + }, + { + elapsed_since_start_ns: 112828800, + thread_id: 0, + stack_id: 26 + }, { elapsed_since_start_ns: 112843800, thread_id: 2, @@ -1036,14 +1085,24 @@ stack_id: 3 }, { - elapsed_since_start_ns: 112863500, - thread_id: 4, - stack_id: 17 + elapsed_since_start_ns: 114797500, + thread_id: 8, + stack_id: 27 }, { elapsed_since_start_ns: 114809100, - thread_id: 6, - stack_id: 18 + thread_id: 9, + stack_id: 28 + }, + { + elapsed_since_start_ns: 118824700, + thread_id: 7, + stack_id: 29 + }, + { + elapsed_since_start_ns: 118832200, + thread_id: 10, + stack_id: 30 } ] -} \ No newline at end of file +} From 922aac06c31895e643ca45b66136be40269f7303 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Tue, 28 May 2024 10:49:32 +0200 Subject: [PATCH 7/7] typo --- src/Sentry.Profiling/SampleProfilerSession.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Sentry.Profiling/SampleProfilerSession.cs b/src/Sentry.Profiling/SampleProfilerSession.cs index cda158fffd..6192d2b821 100644 --- a/src/Sentry.Profiling/SampleProfilerSession.cs +++ b/src/Sentry.Profiling/SampleProfilerSession.cs @@ -17,7 +17,7 @@ internal class SampleProfilerSession : IDisposable private readonly TraceLogEventSource _eventSource; private readonly MutableTraceEventStackSource _stackSource; private readonly SampleProfilerTraceEventParser _sampleEventParser; - private readonly SymbolReader _symboReader; + private readonly SymbolReader _symbolReader; private readonly ActivityComputer _activityComputer; // private readonly StartStopActivityComputer _startStopActivityComputer; private readonly IDiagnosticLogger? _logger; @@ -30,8 +30,8 @@ private SampleProfilerSession(SentryStopwatch stopwatch, EventPipeSession sessio _logger = logger; _eventSource = eventSource; _sampleEventParser = new SampleProfilerTraceEventParser(_eventSource); - _symboReader = new SymbolReader(TextWriter.Null); - _activityComputer = new ActivityComputer(eventSource, _symboReader); + _symbolReader = new SymbolReader(TextWriter.Null); + _activityComputer = new ActivityComputer(eventSource, _symbolReader); // _startStopActivityComputer = new StartStopActivityComputer(eventSource, _activityComputer); _stopwatch = stopwatch; _stackSource = new MutableTraceEventStackSource(eventSource.TraceLog) @@ -141,7 +141,7 @@ public void Stop() _stopped = true; _session.Stop(); _session.Dispose(); - _symboReader.Dispose(); + _symbolReader.Dispose(); _eventSource.Dispose(); } catch (Exception ex)