-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
[WIP] tracing: replacing trace_events with perfetto #35900
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
e9dd3da
to
afc1c37
Compare
This is still experimental. This enables the use of perfetto as a replacement for the existing trace events mechanism in Node.js. It's a significant change that impacts both v8 and core. The build is still imperfect and needs some work. To enable perfetto, use `./configure --use-perfetto`. Running `make` after will likely fail the first time through, but should pass the second. * The tracing format is changed from json to streamed protobufs. * The existing tracing categories are changed. * The JavaScript trace API has been changed completely. This will be a breaking change to any code that builds on the existing trace system. There is still more here to do before this is ready to land.
Ping @nodejs/diagnostics ... any thoughts on this? It's still definitely a work in progress and has a ways to go but it would be good to get some input on it before I dedicate much more time to it. |
I have a few questions to get this into the right viewpoint:
I assume the main target audience for this are the current users of trace-events. I have never used trace-events by myself and I have never seen anyone asking here for traces to analyze an issue. |
It looks very promising, as previously said would nice some input to check the workflow.
If landed, we'll create a specific mirror for it? |
This is a replacement to the existing trace events subsystem in core. See trace_events.md for details on what is currently traced.
The current trace events mechanism is not exposed to end users except to allow users to enable/disable them. This will be similar at first but I do have plans to expose a user-facing API.
Diagnostic tooling. For example, our clinic.js tooling uses the trace events generated for async hooks. It would be the same.
They are separate. Trace events long predate the newly added diagnostic channel. Perfetto is just a replacement for the underlying engine that supports those trace events.
No, we wouldn't land this until it supports all Node.js supported platforms. This is just an early work in progress. |
Realistically, what are the chances of perfetto being abandoned by Google? I'd like to avoid a repeat of gyp if possible. |
I have concerns there also @cjihrig but the fact that it's a dependency of android and there are ABI stability guarantees, I'd say it's a fairly safe bet. It is also significantly better and more robust than the partial existing trace events implementation that was written by folks at google but never finished. |
Not a huge fan of how much ifdef stuff this piles onto the code everywhere. Hopefully we can stabilize this and delete those relatively quickly. 😬 Also, might be a good idea to keep the old and new tracing files separate. The file structure is not super clear where the division is. Other than that, seems like you're on track to something usable. :) |
This is a work in progress preview of integrating perfetto as a replacement
for the trace events subsystem.
This is no where near complete. I'm opening it early to start getting feedback.
Perfetto (https://perfetto.dev) is a tracing subsystem created by Google and used
in Android and Chrome. It supports both in-process and out-of-process with the
ability to integrate application and system traces.
The traces generated are emitted as encoded protobufs rather than JSON, and the
subsystem is much more stable and robust than the existing unfinished tracing
support we currently have.
Unfortunately, it's also much more complex, with large new dependencies and a
complicated configuration model.
Perfetto will allow richer and more flexible diagnostic tracing use cases,
including the ability to stream tracing data in-process (something we currently
cannot do easily). The traces are more efficient at runtime, take less memory
and disk space, and generally work better.
Currently, this will likely only build on Linux systems (I've only tested on
Ubuntu to this point). It will definitely fail on Windows, and DEFINITELY
will not pass CI in any way shape or form. There's still a ton of work to do
here (including reducing the size of the added dependencies)
Notes
To build with perfetto:
(there's currently a bug in the building step, first time through, it will likely fail, just run
make -4
again and it should be ok. It's an open todo to fix it)Once built, running with the regular command line options (e.g.
--trace-event-categories=v8,node
) will cause the trace event file to be emitted. Currently, perfetto is being invoked with verbose logging enabled to allow easier debugging, that will be turned off a bit later once I'm sure everything is working right.The trace event file will be a binary sequence of serialized protobufs rather than a json document. It needs to be loaded into the perfetto UI to be processed. The legacy
chrome://tracing
will not workTraces from JavaScript (e.g. trace events for
AsyncResource
andconsole.time()
are emitted as legacy trace events. I will be converting those over into the new model soon.The entire current
trace_events
module will be completely redone. The existing API no longer makes sense and is not supportable. Fortunately, it's still considered experimental but we should still consider it a breaking change. A new API is being implemented that allows for some very interesting options... this is not yet fully implemented but here's an example of what will be possible:This will create a new tracing session that pipes traces into a stream rather than out to file. The file trace and the stream trace are independent of each other but can have overlapping information if both are enabled at the same time.
There are a number of other features that are planned as this progresses, such as the ability to limit trace file size, apply compression to the trace output automatically, support tracing via the Inspector protocol, provide trace triggers, provide a user-accessible JavaScript API for emitting traces, and more.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes