rust-lang / rustc-perf

Website for graphing performance of rustc
https://perf.rust-lang.org
604 stars 147 forks source link

Embed query traces in the web UI #1857

Open Kobzol opened 4 months ago

Kobzol commented 4 months ago

Currently, if we want to open a query trace gathered from a self-profile, we need to go through ui.perfetto.dev. It takes considerable time to load and redirects to an external website.

It would be nice to integrate the visualization of the query trace directly within our website, e.g. using https://chromium.googlesource.com/catapult/+/HEAD/tracing/README.md or something similar.

Daksh-10 commented 3 months ago

On Chromium's issue list, it says that the browser's trace viewer will be replaced by Perfetto UI (maybe it provides better trace viewing features) . I also checked it takes time to redirect to the website, so should I work on it considering the 'replacement' point.

Kobzol commented 3 months ago

The main goal is to embed some visualization of traces within our web. I don't really care which visualization it is, as long as it works. If the used solution will be deprecated in the future, that doesn't have to concern us, as long as it will work in perf.RLO. And even if we had to replace it in the future, there will be some additional work that has to be done on the website that will be shared by all potential solutions, so it shouldn't be that difficult to replace the visualizer.

There are multiple open source trace visualizers, I would choose the one that's the easiest to embed.

Daksh-10 commented 3 months ago

Catapult traceviewer is not well documented, it only explains how to embed the traceviewer which I did, but it doesn't explain how will we create a tracefile (with .json.gz or .json.zip extension which is required) for a specified task, so I am not able to work on it further, can you suggest any documentation which explains it. (The closest I got was 'ftarce' for linux kernel).

Kobzol commented 3 months ago

rustc-perf already exports Chrome-compatible traces from rustc self-profile data, e.g. https://perf.rust-lang.org/perf/processed-self-profile?commit=b57a10c39d2a2da7389d029595d7fff6ac9cbf5a&benchmark=unicode-normalization-0.1.19-check&scenario=full&type=crox (taken from https://perf.rust-lang.org/detailed-query.html?commit=b57a10c39d2a2da7389d029595d7fff6ac9cbf5a&benchmark=unicode-normalization-0.1.19-check&scenario=full).

So if you can embed the visualizer, and point it to a URL address on perf.RLO, then that should be all (we might need to add a new endpoint that exports the data in the format that the visualiser expects).

s7tya commented 2 months ago

As previously mentioned, several other projects using Catapult are migrating to Perfetto due to its unmaintained and deprecated status. There are already some bugs in Catapult.

https://github.com/golang/go/issues/57315#issuecomment-1353394253

They also discussed the trace packet proto, which is a protobuf format of trace data. It's noted to be somewhat smaller than JSON, potentially improving loading times.

https://perfetto.dev/docs/reference/trace-packet-proto

I'm curious about which way is better. I would like to test this format to evaluate how difficult it is to implement and how fast it loads. Based on the results, I will decide whether to use Catapult or keep using Perfetto with protobuf format export.

Additionally, if we decide to use Catapult, we might not be able to package everything into a single binary because Catapult uses Python and they don't distribute binaries.

(I'm not entirely sure about this, but there seems to be an option to process traces on the server side. I should look into this further.) https://perfetto.dev/docs/visualization/large-traces

Kobzol commented 2 months ago

We can probably generate any format we like on the rustc-perf backend, so that shouldn't be a concern. The main goal is to enable displaying the traces within our own UI, without forcing the user to go to an external website (and especially to Perfetto, because it loads quite slowly and without any user indication of the loading duration, for security reasons).

s7tya commented 2 months ago

Hmm, alright, then I'll try to integrate Catapult into rustc-perf!