Skip to content
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
68bafaa
wip: in-memory tracelog
vaind May 4, 2023
f6657f5
in-memory tracelog support
vaind May 5, 2023
9f8727f
profiler - remove temp dir
vaind May 8, 2023
3833b5f
tracelog streaming
vaind May 8, 2023
ad5e21f
fix sample collection
vaind May 9, 2023
1510734
migrate downsampling & fix tests
vaind May 9, 2023
886a2e9
fix: SparseArray
vaind May 10, 2023
2b70a79
update benchmark & profile builder
vaind May 10, 2023
ba3b4e1
minor changes rundown issue investigation
vaind May 11, 2023
079a72c
Merge branch 'main' into feat/streaming-tracelog
vaind May 18, 2023
25592ba
separate rundown session during tracelog init
vaind May 19, 2023
aa3ff4d
fixes
vaind May 20, 2023
3f7b063
Merge branch 'main' into feat/streaming-tracelog
vaind May 22, 2023
9a780eb
update profiling benchmark results
vaind May 22, 2023
61d2718
Merge branch 'main' into feat/streaming-tracelog
vaind May 22, 2023
cc6119f
update tests
vaind May 23, 2023
9005697
Merge branch 'main' into feat/streaming-tracelog
vaind May 23, 2023
f88a20d
update tests
vaind May 23, 2023
f864e7c
fixes
vaind May 23, 2023
04d38a5
update tests to support streaming tracelog
vaind May 30, 2023
8b3691d
Merge branch 'main' into feat/streaming-tracelog
vaind May 30, 2023
9b51611
Merge branch 'main' into feat/streaming-tracelog
vaind Jun 4, 2023
d171989
Merge branch 'main' into feat/streaming-tracelog
vaind Aug 4, 2023
c7f6929
update to latest perfview
vaind Aug 4, 2023
5b159e1
fix test code
vaind Aug 16, 2023
f457e3a
Merge branch 'main' into feat/streaming-tracelog
vaind Aug 16, 2023
b4693e8
Merge branch 'main' into feat/streaming-tracelog
vaind Aug 21, 2023
2634169
Squashed commit of the following (PR #2555):
vaind Aug 21, 2023
670b6fe
perfview submodule setup - unalatered branch
vaind Aug 21, 2023
e89d574
chore: update changelog
vaind Aug 21, 2023
b7ca7b4
fixup: squash
vaind Aug 21, 2023
33e59c6
build
bruno-garcia Aug 22, 2023
4e4b63e
Merge branch 'main' into feat/streaming-tracelog
bruno-garcia Aug 22, 2023
11f2b34
add perfview feed
bruno-garcia Aug 22, 2023
223913a
ms feed pkg
bruno-garcia Aug 22, 2023
1617ef2
ms feed pkg
bruno-garcia Aug 22, 2023
0f5fc2f
ms feed pkg
bruno-garcia Aug 22, 2023
d970fbf
ms feed pkg
bruno-garcia Aug 22, 2023
12e53e5
test: profiler snapshot update
vaind Aug 22, 2023
7a00db9
fix CI
vaind Aug 23, 2023
ba89304
update perfview
vaind Aug 23, 2023
614ae76
fix CI
vaind Aug 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
path = modules/Carthage
url = https://github.com/Carthage/Carthage
branch = xcframework-catalyst
[submodule "modules/perfview"]
path = modules/perfview
url = https://github.com/getsentry/perfview.git
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Features

- Graphql client ([#2538](https://github.com/getsentry/sentry-dotnet/pull/2538))
- Profiling multiple transactions in parallel ([#2385](https://github.com/getsentry/sentry-dotnet/pull/2385))

### Dependencies

Expand Down
3 changes: 2 additions & 1 deletion Sentry-CI-Pack.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
"src\\Sentry.Maui\\Sentry.Maui.csproj",
"src\\Sentry.NLog\\Sentry.NLog.csproj",
"src\\Sentry.OpenTelemetry\\Sentry.OpenTelemetry.csproj",
"src\\Sentry.Profiling\\Sentry.Profiling.csproj",
"src\\Sentry.Serilog\\Sentry.Serilog.csproj",
"src\\Sentry\\Sentry.csproj"
]
}
}
}
1 change: 1 addition & 0 deletions Sentry-CI-Test.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"test\\Sentry.Serilog.Tests\\Sentry.Serilog.Tests.csproj",
"test\\Sentry.Testing.CrashableApp\\Sentry.Testing.CrashableApp.csproj",
"test\\Sentry.Testing\\Sentry.Testing.csproj",
"test\\Sentry.Profiling.Tests\\Sentry.Profiling.Tests.csproj",
"test\\Sentry.Tests\\Sentry.Tests.csproj"
]
}
Expand Down
902 changes: 435 additions & 467 deletions Sentry.Full.sln

Large diffs are not rendered by default.

768 changes: 355 additions & 413 deletions Sentry.sln

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion SentryCore.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
"solution": {
"path": "Sentry.sln",
"projects": [
"benchmarks\\Sentry.Benchmarks\\Sentry.Benchmarks.csproj",
"samples\\Sentry.Samples.Console.Basic\\Sentry.Samples.Console.Basic.csproj",
"samples\\Sentry.Samples.Console.Profiling\\Sentry.Samples.Console.Profiling.csproj",
"src\\Sentry.Profiling\\Sentry.Profiling.csproj",
"src\\Sentry\\Sentry.csproj",
"test\\Sentry.Profiling.Tests\\Sentry.Profiling.Tests.csproj",
"test\\Sentry.Testing.CrashableApp\\Sentry.Testing.CrashableApp.csproj",
"test\\Sentry.Testing\\Sentry.Testing.csproj",
"test\\Sentry.Tests\\Sentry.Tests.csproj"
]
}
}
}

Large diffs are not rendered by default.

78 changes: 34 additions & 44 deletions benchmarks/Sentry.Benchmarks/ProfilingBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -1,41 +1,59 @@
using System.Diagnostics.Tracing;
using BenchmarkDotNet.Attributes;
using Microsoft.Diagnostics.NETCore.Client;
using Microsoft.Diagnostics.Tracing.Parsers;
using NSubstitute;
using Sentry.Internal;
using Sentry.Profiling;

namespace Sentry.Benchmarks;

extern alias BenchmarkDotNetTransientTraceEvent;

public class ProfilingBenchmarks
{
private IHub _hub = Substitute.For<IHub>();
private ITransactionProfilerFactory _factory = new SamplingTransactionProfilerFactory(Path.GetTempPath(), new());
private SamplingTransactionProfilerFactory _factory;
private ITransactionProfiler _profiler;

[GlobalSetup(Targets = new string[] { nameof(Transaction), nameof(DoHardWorkWhileProfiling) })]
public void StartProfiler()
{
_factory = SamplingTransactionProfilerFactory.Create(new());
}

[GlobalCleanup(Targets = new string[] { nameof(Transaction), nameof(DoHardWorkWhileProfiling) })]
public void StopProfiler()
{
_profiler?.Finish();
_profiler?.CollectAsync(new Transaction("", "")).Wait();
_profiler = null;
_factory.Dispose();
_factory = null;
}

#region full transaction profiling
public IEnumerable<object[]> ProfilerArguments()
public IEnumerable<object[]> TransactionBenchmarkArguments()
{
foreach (var runtimeMs in new[] { 25, 100, 1000, 10000 })
{
foreach (var processing in new[] { true, false })
foreach (var collect in new[] { true, false })
{
yield return new object[] { runtimeMs, processing };
yield return new object[] { runtimeMs, collect };
}
}
}

// Run a profiled transaction. Profiler starts and stops for each transaction separately.
[Benchmark]
[ArgumentsSource(nameof(ProfilerArguments))]
public long Transaction(int runtimeMs, bool processing)
[ArgumentsSource(nameof(TransactionBenchmarkArguments))]
public long Transaction(int runtimeMs, bool collect)
{
var tt = new TransactionTracer(_hub, "test", "");
tt.TransactionProfiler = _factory.Start(tt, CancellationToken.None);
var result = RunForMs(runtimeMs);
tt.TransactionProfiler?.Finish();
tt.TransactionProfiler.Finish();
var transaction = new Transaction(tt);
if (processing)
if (collect)
{
var collectTask = tt.TransactionProfiler.CollectAsync(transaction);
collectTask.Wait();
Expand Down Expand Up @@ -97,11 +115,7 @@ public DiagnosticsClient DiagnosticsClientNew()
[Benchmark]
public void DiagnosticsSessionStartStop()
{
var session = DiagnosticsClientNew().StartEventPipeSession(
SampleProfilerSession.Providers,
SampleProfilerSession.RequestRundown,
SampleProfilerSession.CircularBufferMB
);
var session = DiagnosticsClientNew().StartEventPipeSession(SampleProfilerSession.Providers, true, SampleProfilerSession.CircularBufferMB);
session.EventStream.Dispose();
session.Dispose();
}
Expand All @@ -125,9 +139,9 @@ public void DiagnosticsSessionStartCopyStop(bool rundown, string provider)
{
EventPipeProvider[] providers = provider switch
{
"runtime" => new[] { new EventPipeProvider("Microsoft-Windows-DotNETRuntime", EventLevel.Informational, (long)ClrTraceEventParser.Keywords.Default) },
"runtime" => new[] { new EventPipeProvider("Microsoft-Windows-DotNETRuntime", EventLevel.Informational, (long)BenchmarkDotNetTransientTraceEvent::Microsoft.Diagnostics.Tracing.Parsers.ClrTraceEventParser.Keywords.Default) },
Copy link
Member

Choose a reason for hiding this comment

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

We'll need to fix this in a follow up PR. Since our customers will experience the same thing. We need to change namespaces, or make stuff internal

Copy link
Contributor Author

Choose a reason for hiding this comment

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

related to #2385 (comment)

"sample" => new[] { new EventPipeProvider("Microsoft-DotNETCore-SampleProfiler", EventLevel.Informational) },
"tpl" => new[] { new EventPipeProvider("System.Threading.Tasks.TplEventSource", EventLevel.Informational, (long)TplEtwProviderTraceEventParser.Keywords.Default) },
"tpl" => new[] { new EventPipeProvider("System.Threading.Tasks.TplEventSource", EventLevel.Informational, (long)BenchmarkDotNetTransientTraceEvent::Microsoft.Diagnostics.Tracing.Parsers.TplEtwProviderTraceEventParser.Keywords.Default) },
"all" => SampleProfilerSession.Providers,
_ => throw new InvalidEnumArgumentException(nameof(provider))
};
Expand All @@ -139,19 +153,10 @@ public void DiagnosticsSessionStartCopyStop(bool rundown, string provider)
session.Dispose();
}

// Same as DiagnosticsSessionStartCopyStop(rundown: true, provider: 'all')
[Benchmark]
public void SampleProfilerSessionStartStopFinishWait()
{
var session = SampleProfilerSession.StartNew(CancellationToken.None);
session.Stop();
session.FinishAsync().Wait();
}

[Benchmark]
public void SampleProfilerSessionStartStop()
{
var session = SampleProfilerSession.StartNew(CancellationToken.None);
using var session = SampleProfilerSession.StartNew();
session.Stop();
}
#endregion
Expand All @@ -163,30 +168,15 @@ public void SampleProfilerSessionStartStop()
[ArgumentsSource(nameof(OverheadRunArguments))]
public long DoHardWork(int n)
{
return ProfilingBenchmarks.FindPrimeNumber(n);
return FindPrimeNumber(n);
}

[BenchmarkCategory("overhead"), Benchmark]
[ArgumentsSource(nameof(OverheadRunArguments))]
public long DoHardWorkWhileProfiling(int n)
{
return ProfilingBenchmarks.FindPrimeNumber(n);
}

private ITransactionProfiler _profiler;

[GlobalSetup(Target = nameof(DoHardWorkWhileProfiling))]
public void StartProfiler()
{
_profiler = _factory.Start(new TransactionTracer(_hub, "", ""), CancellationToken.None);
}

[GlobalCleanup(Target = nameof(DoHardWorkWhileProfiling))]
public void StopProfiler()
{
_profiler?.Finish();
_profiler?.CollectAsync(new Transaction("", "")).Wait();
_profiler = null;
_profiler ??= _factory.Start(new TransactionTracer(_hub, "", ""), CancellationToken.None);
return FindPrimeNumber(n);
}
#endregion
}
8 changes: 8 additions & 0 deletions benchmarks/Sentry.Benchmarks/Sentry.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,12 @@
<ProjectReference Include="..\..\src\Sentry.Profiling\Sentry.Profiling.csproj" />
</ItemGroup>

<!-- BenchmarkDotNet depends on Microsoft.Diagnostics.Tracing.TraceEvent which includes types we're vendoring in Sentry through the perview submodule.-->
<Target Name="ChangeAliasesOfStrongNameAssemblies" BeforeTargets="FindReferenceAssembliesForReferences;ResolveReferences">
<ItemGroup>
<ReferencePath Condition="'%(FileName)' == 'Microsoft.Diagnostics.Tracing.TraceEvent'">
<Aliases>BenchmarkDotNetTransientTraceEvent</Aliases>
</ReferencePath>
</ItemGroup>
</Target>
</Project>
2 changes: 1 addition & 1 deletion benchmarks/Sentry.Benchmarks/run.cmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set framework=netcoreapp2.1
set framework=net6.0

dotnet build -c Release -f %framework%
if not errorlevel 0 exit /b -1
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/Sentry.Benchmarks/run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
set -e errexit

framework=netcoreapp2.1
framework=net6.0
dotnet build -c Release -f $framework
dotnet bin/Release/$framework/Sentry.Benchmarks.dll
1 change: 1 addition & 0 deletions modules/perfview
Submodule perfview added at 53024e
Loading