Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7c09e43
initial LttngProfiler implementation
adamsitnik Jun 9, 2019
c4921ad
download the script to the right folder
adamsitnik Jun 9, 2019
c59b96d
escepe the arguments, wait until it starts actual collection, don't g…
adamsitnik Jun 9, 2019
4171885
wait until the script ends post-processing
adamsitnik Jun 9, 2019
77e3a52
use Mono.Posix to send SIGINT (Ctrl+C) to the script
adamsitnik Jun 9, 2019
11c5e06
more changes
adamsitnik Jul 1, 2019
eedf8c0
Merge remote-tracking branch 'origin/master' into perfCollectDiagnoser
adamsitnik Mar 3, 2020
2c63c4c
remove duplicated code
adamsitnik Mar 3, 2020
c77e7df
add perfcollect to the resources, don't download it
adamsitnik Mar 3, 2020
93330c2
update doc link
adamsitnik Mar 3, 2020
bd7ceb0
use the new start and stop commands
adamsitnik Mar 3, 2020
8472f20
use the new install -force option which allows us to avoid user being…
adamsitnik Mar 16, 2020
f08473b
Merge branch 'master' into perfCollectDiagnoser
adamsitnik Sep 20, 2022
c2d8bf7
refresh perfcollect
adamsitnik Sep 20, 2022
4ffdf5d
use collect command, stop in with Ctrl+C by sending SIGINT
adamsitnik Sep 22, 2022
a6086f8
add an attribute and a sample
adamsitnik Sep 22, 2022
e85c830
enable BDN event source
adamsitnik Sep 22, 2022
d2db654
emit an error when perfcollect finishes sooner than expected (most li…
adamsitnik Sep 23, 2022
220dcde
escape the arguments, store the result only if file was created, get …
adamsitnik Sep 26, 2022
194f4bf
turn off precompiled code to resolve framework symbols without using …
adamsitnik Sep 27, 2022
c0d692a
install dotnet symbols to get symbols for native runtime parts
adamsitnik Sep 27, 2022
7191b6b
add workaround for https://github.com/dotnet/runtime/issues/71786
adamsitnik Sep 28, 2022
bb0c66d
download symbols for all .so files
adamsitnik Sep 28, 2022
5b04d07
polishing: new short name (perf instead PC), running for multiple run…
adamsitnik Sep 28, 2022
5201ed1
don't turn off precompiled code
adamsitnik Sep 28, 2022
7819a20
final polishing before merging
adamsitnik Sep 29, 2022
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
Prev Previous commit
Next Next commit
refresh perfcollect
  • Loading branch information
adamsitnik committed Sep 20, 2022
commit c2d8bf72530694ebdb3f083fc2ad9ed02efaf438
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/Diagnosers/DiagnosersLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private static IEnumerable<IDiagnoser> LoadDiagnosers()
yield return EventPipeProfiler.Default;

if (RuntimeInformation.IsLinux())
yield return LttngProfiler.Default;
yield return PerfCollectProfiler.Default;
}

if (!RuntimeInformation.IsWindows())
Expand Down
24 changes: 12 additions & 12 deletions src/BenchmarkDotNet/Diagnosers/LttngProfiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@

namespace BenchmarkDotNet.Diagnosers
{
public class LttngProfiler : IProfiler
public class PerfCollectProfiler : IProfiler
{
private const int SuccesExitCode = 0;
private const string PerfCollectFileName = "perfcollect";

public static readonly IDiagnoser Default = new LttngProfiler(new LttngProfilerConfig(performExtraBenchmarksRun: false));
public static readonly IDiagnoser Default = new PerfCollectProfiler(new PerfCollectProfilerConfig(performExtraBenchmarksRun: false));

private readonly LttngProfilerConfig config;
private readonly PerfCollectProfilerConfig config;
private readonly DateTime creationTime = DateTime.Now;
private readonly Dictionary<BenchmarkCase, FileInfo> benchmarkToTraceFile = new Dictionary<BenchmarkCase, FileInfo>();

[PublicAPI]
public LttngProfiler(LttngProfilerConfig config) => this.config = config;
public PerfCollectProfiler(PerfCollectProfilerConfig config) => this.config = config;

public string ShortName => "LTTng";
public string ShortName => "PC";

public IEnumerable<string> Ids => new[] { nameof(LttngProfiler) };
public IEnumerable<string> Ids => new[] { nameof(PerfCollectProfiler) };

public IEnumerable<IExporter> Exporters => Array.Empty<IExporter>();

Expand All @@ -47,19 +47,19 @@ public IEnumerable<ValidationError> Validate(ValidationParameters validationPara
{
if (!RuntimeInformation.IsLinux())
{
yield return new ValidationError(true, "The LttngProfiler works only on Linux!");
yield return new ValidationError(true, "The PerfCollectProfiler works only on Linux!");
yield break;
}

if (Mono.Unix.Native.Syscall.getuid() != 0)
{
yield return new ValidationError(true, "You must run as root to use LttngProfiler.");
yield return new ValidationError(true, "You must run as root to use PerfCollectProfiler.");
yield break;
}

if (validationParameters.Benchmarks.Any() && !TryInstallPerfCollect(validationParameters))
{
yield return new ValidationError(true, "Failed to install perfcollect script. Please follow the instructions from https://github.com/dotnet/runtime/blob/master/docs/project/linux-performance-tracing.md");
yield return new ValidationError(true, "Failed to install perfcollect script. Please follow the instructions from https://github.com/dotnet/runtime/blob/main/docs/project/linux-performance-tracing.md");
}
}

Expand Down Expand Up @@ -163,7 +163,7 @@ private void ExecutePerfCollectCommand(DiagnoserActionParameters parameters, Fil
var logger = parameters.Config.GetCompositeLogger();

logger.WriteLineError($"The perfcollect script did not start/stop in {config.Timeout.TotalSeconds}s.");
logger.WriteLineInfo("You can create LttngProfiler providing LttngProfilerConfig with custom timeout value.");
logger.WriteLineInfo("You can create PerfCollectProfiler providing PerfCollectProfilerConfig with custom timeout value.");

logger.Flush(); // flush recently logged message to disk

Expand All @@ -180,11 +180,11 @@ private void ExecutePerfCollectCommand(DiagnoserActionParameters parameters, Fil
}
}

public class LttngProfilerConfig
public class PerfCollectProfilerConfig
{
/// <param name="performExtraBenchmarksRun">if set to true, benchmarks will be executed one more time with the profiler attached. If set to false, there will be no extra run but the results will contain overhead. True by default.</param>
/// <param name="timeoutInSeconds">how long should we wait for the perfcollect script to start collecting and/or finish processing the trace. 30s by default</param>
public LttngProfilerConfig(bool performExtraBenchmarksRun = true, int timeoutInSeconds = 60)
public PerfCollectProfilerConfig(bool performExtraBenchmarksRun = true, int timeoutInSeconds = 60)
{
RunMode = performExtraBenchmarksRun ? RunMode.ExtraRun : RunMode.NoOverhead;
Timeout = TimeSpan.FromSeconds(timeoutInSeconds);
Expand Down
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/Extensions/ProcessExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ internal static void SetEnvironmentVariables(this ProcessStartInfo start, Benchm
if (benchmarkCase.Job.Environment.Runtime is MonoRuntime monoRuntime && !string.IsNullOrEmpty(monoRuntime.MonoBclPath))
start.EnvironmentVariables["MONO_PATH"] = monoRuntime.MonoBclPath;

if (benchmarkCase.Config.GetDiagnosers().OfType<LttngProfiler>().Any())
if (benchmarkCase.Config.GetDiagnosers().OfType<PerfCollectProfiler>().Any())
{
start.EnvironmentVariables["COMPlus_PerfMapEnabled"] = "1";
start.EnvironmentVariables["COMPlus_EnableEventLog"] = "1";
Expand Down
Loading