google / perfetto

Performance instrumentation and tracing for Android, Linux and Chrome (read-only mirror of https://android.googlesource.com/platform/external/perfetto/)

Home Page:https://www.perfetto.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Chromium v8 JavaScript (JS) stacks in Perfetto?

ivberg opened this issue · comments

It seems that the tracing probes and infrastructure are highly shared between F12 perf dev tools & Perfetto.

It seems F12 Dev Tools enables some categories that Perfetto UI Chrome tracing supports. Things like these categories

  • v8.runtime_stats_sampling
  • v8.cpu_profiler

Again these can be collected by Perfetto. Additionally, a F12 profile with JS stacks can be saved and loaded by Perfetto.

However, it doesn't seem like Perfetto has support for these. There is no UI to show them and the SQL query interface does now show /expose data under cpu_profile_stack_sample no matter if the trace was taken in Perfetto or F12 Profile JSON

However, it doesn't seem like Perfetto has support for these. There is no UI to show them and the SQL query interface does now show /expose data under cpu_profile_stack_sample no matter if the trace was taken in Perfetto or F12 Profile JSON

That's correct, perfetto UI and trace processor never had any support for JS callstack samples. The data is really just plumbed through (only some paths even, IIRC, only the JSON exported) and then the chrome devtools backend ingests it.

Historical reasons, if you ask. The v8 profilers were written by devtools and tracing was not fully there IIRC. Then tracing came along but nobody ever merged the two paths. There is no big plan to do so, because v8 profilers are typically aimed at web developers (who use devtools) and trace events are aimed at browser engineers.

Don't get me wrong, it would be nice if they were consistently supported in all tools. But this is by no means a priority for anybody, and as such will probably not bubble up in the next N years.

Thx @primiano . It's always refreshing & nice to hear the context / history here and the reality with respect to priorities and feature support. I appreciate it!

Since the title of this issue is "Chromium v8 JavaScript (JS) stacks in Perfetto?" I think that's 1 interesting future scenario. However, mixed with this is what you also responded to.

The data is really just plumbed through (only some paths even, IIRC, only the JSON exported) and then the chrome devtools backend ingests it.

From what I can tell, this scenario doesn't fully work. I am opening a 2nd issue on that #277 (Perfetto Chromium Trace Capture should support capturing / exporting to DevTools (bug?)) that more clearly outlines the issue and the scenario - which I think is more compelling priority wise than this issue IMO given everything you mentioned.

Abstractly speaking how far is the sampling information propagated at the moment?

I'd be willing to do build the sampling profiler UI as a side-project depending on how much complexity lies within accessing/providing the sampling information in perfetto.

Is the cpu_profile_stack_sample a reasonable place for V8 JS stack samples to end up?

This looks like it would have all the necessary information to work with JS as well (unsurprisingly :P).

Is the cpu_profile_stack_sample a reasonable place for V8 JS stack samples to end up?

Yes it should be. Pretty sure when we were defining the table, we had some consultation with the Chrome folks to ensure it would work for their usecase.

Teams here at Microsoft are frequently hitting the issue of JS stacks not being available in Perfetto's UI. Any progress towards this would be helpful, as juggling multiple tools (DevTools/Perfetto) for a single trace reduces analyst confidence and speed.

Primiano's comment from #275 (comment) is still the latest state of affairs: this is not considered a priority by us or any team we are aware of in Google so there is no timeline on when it might be addressed.

If there's interest from a team at Microsoft who wants to address this, we're very happy to help guide on the design and implementation.

Hi I'm from the V8 team and it is definitely been a prio for us (see internal doc https://docs.google.com/document/d/1UPZAWjLUNhEieAkzPU4Gp5xARuXGtu3IbxQqjAglAIk/edit?usp=sharing)

And the main issue is the same for us, switching between DevTools and perfetto is not particularly efficient. And DevTools has mostly opted for stripping low-level debugging features in favour of a simpler and more accessible UI.

This is something that's keeping me on chrome://tracing and preventing me from switching to use Perfetto. Being able to correlate V8 samples with other things happening in a trace is pretty useful!