Replies: 1 comment 3 replies
-
I love this idea. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Expose a new flag,
--trace
or similar to emit profiling trace for SWC's internal behavior as trace event format.Motivation
Performance is one of the notable characteristics of SWC. While SWC itself needs to deliver consistent peak performance, there will be problems from end user's codebases. By providing trace capabilities from SWC's core itself user can have detailed diagnostics to their own problem, also it can be used for the tracing for observability.
Slack for example heavily utilizes chrome's tracing feature for internal perf analysis (https://slack.engineering/chrome-tracing-for-fun-and-profit/) for their desktop client to solve real world user performance issue cannot be reproducible internally.
Explainer
Trace Event format is JSON representation of trace event data can be processed via various tools, including trace viewer. Chrome uses it for its trace profiling (https://www.chromium.org/developers/how-tos/trace-event-profiling-tool) as well as other tools like Bazel (https://docs.bazel.build/versions/main/skylark/performance.html). Chrome has an embedded trace viewer for the visualization (chrome://tracing/).
Detailed design
Thankfully, there are rust ecosystem allows us to adapt this easily. Moreover, SWC already have
tracing
(https://github.com/tokio-rs/tracing) internally. There is a layertracing_chrome
(https://github.com/thoren-d/tracing-chrome) on top of tracing subscriber which generates Event Trace Format JSON output from existing traces.This PR (#3066) have quick & dirty poc demo which enables chrome traces with few dummy spans for
transform_sync
. Please refer generated JSON for the output format which can be visualized as below.As a consumer's point of view, I expect these kinds of pseudo workflow to generate traces for a given operation.
categories
: this indicates which part of trace will be recorded. For example, there can be categories likeecma_parser
/ecma_transforms
. As illustrated in second example, it is possible to apply some wildcard behavior. This mimics chromium's behavior for its categoryFilterDrawbacks
Alternatives
Not much. Do not think it is worth to invent something new for swc only especially we have some of infrastructures in our codes.
Unresolved questions
There are multiple open questions / tasks that need to be resolved to make this happen. Notably,
Beta Was this translation helpful? Give feedback.
All reactions