JetBrains / profiler-self-api

The portable version of JetBrains profiler self API for .NET Framework / .NET Core / .NET / .NET Standard
Apache License 2.0
61 stars 8 forks source link

Timeline profiling is not supported under Linux #4

Open dziedrius opened 2 years ago

dziedrius commented 2 years ago

Even if I can run timeline profiling under linux just fine from command line (with both - start and attach), profiling self API says it is not supported.

I've cloned code repo, removed

if (Helper.Platform != PlatformId.Windows)
    throw new InvalidOperationException("The Timeline profiling type is supported only on Windows platform");

and used compiled package instead of official one from releases, hoping that it is just leftover from previous versions, when it was actually not supported, but seems that it did not help:

JetBrains.Profiler.SelfApi Verbose: 1 : Prerequisite.TryGetRunner: `dottrace`
JetBrains.Profiler.SelfApi Verbose: 2 : Prerequisite.TryGetRunner: External path provided, looking at `/opt/dottrace/dottrace`
JetBrains.Profiler.SelfApi Verbose: 3 : Prerequisite[dotTrace].DownloadAsync: Runner found, no async task needed.
JetBrains.Profiler.SelfApi Verbose: 4 : DotTrace.RunConsole: Looking for runner...
JetBrains.Profiler.SelfApi Verbose: 5 : Prerequisite.TryGetRunner: `dottrace`
JetBrains.Profiler.SelfApi Verbose: 6 : Prerequisite.TryGetRunner: External path provided, looking at `/opt/dottrace/dottrace`
JetBrains.Profiler.SelfApi Information: 7 : DotTrace.RunConsole:
runner = `/opt/dottrace/dottrace`
arguments = `attach 1 --profiling-type=Timeline --service-input=stdin --service-output=On --collect-data-from-start=Off --use-api "--save-to=/tmp/traces"`
JetBrains.Profiler.SelfApi Verbose: 8 : DotTrace.RunConsole: Runner started.
JetBrains.Profiler.SelfApi Verbose: 9 : dotTrace command-line profiler 2021.3.2 build 777.0.20211221.134946. Copyright (C) 2021 JetBrains s.r.o.
JetBrains.Profiler.SelfApi Verbose: 10 : Profiling in progress...
JetBrains.Profiler.SelfApi Verbose: 11 : ##dotTrace["ready"]
JetBrains.Profiler.SelfApi Verbose: 12 : You can control profiling by sending command messages to stdin. For details, type ##dotTrace["help"]
JetBrains.Profiler.SelfApi Verbose: 13 : use_api == false [location] = /opt/buildAgent/work/6f2bec0cd9673e5e/EtwService/Native/Solution/event_pipe_timeline_profiler/src/netcore_profiler_brige_proto.hpp(48) [function] = virtual std::shared_ptr<prof_a
pi_base> jb_prof::netcore::netcore_profiler_bridge_proto::create_prof(const jb_prof::timeline_info &, bool, const jb_prof::init_data &, std::unique_ptr<bridge_notifier> &&) const
Unhandled exception. System.InvalidOperationException: Profiler.Api was not ready in given time. See details below.
*** Standard Error ***
use_api == false [location] = /opt/buildAgent/work/6f2bec0cd9673e5e/EtwService/Native/Solution/event_pipe_timeline_profiler/src/netcore_profiler_brige_proto.hpp(48) [function] = virtual std::shared_ptr<prof_api_base> jb_prof::netcore::netcore_profil
er_bridge_proto::create_prof(const jb_prof::timeline_info &, bool, const jb_prof::init_data &, std::unique_ptr<bridge_notifier> &&) const

*** Standard Output ***
dotTrace command-line profiler 2021.3.2 build 777.0.20211221.134946. Copyright (C) 2021 JetBrains s.r.o.
Profiling in progress...
##dotTrace["ready"]
You can control profiling by sending command messages to stdin. For details, type ##dotTrace["help"]
at JetBrains.Profiler.SelfApi.Impl.ConsoleProfiler.BuildException(String caption) in C:\temp\profiler-self-api\src\Impl\ConsoleProfiler.cs:line 170
at JetBrains.Profiler.SelfApi.Impl.ConsoleProfiler.AwaitConnected(Int32 milliseconds) in C:\temp\profiler-self-api\src\Impl\ConsoleProfiler.cs:line 191
at JetBrains.Profiler.SelfApi.DotTrace.Session.AwaitConnected(Int32 milliseconds) in C:\temp\profiler-self-api\src\DotTrace.cs:line 540
at JetBrains.Profiler.SelfApi.DotTrace.Attach(Config config) in C:\temp\profiler-self-api\src\DotTrace.cs:line 206
gassanosh commented 2 years ago

Timeline profiling is not supported under Linux yet - it's true (if we are talking about self api). That's why self api throws InvalidOperationException is such case. As soon as clt will support all necessary features for self api the assertion will be removed. Here is a linked issue in JetBrains tracker: https://youtrack.jetbrains.com/issue/PROF-1166

dziedrius commented 2 years ago

But it works from command line in linux and from what I saw in self profile output it constructs command line :) And from output it even looks like profiling is started, just .net wrapper or smth is not seeing it.

gassanosh commented 2 years ago

Profiler has many features. You can start profiling and collect data having only few of them. For self api you need some more features as I said before. In other words "I can start profiling" != "clt can be used with self api".

dziedrius commented 2 years ago

Ok, thanks for explanation.