evmar / n2

n2 ("into"), a ninja compatible build system

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: add commands to create and analyze a (chrome::tracing) build profile

petr-tik opened this issue · comments

As a developer working on large Cpp codebases,
I would like my build system to give me a detailed profile of the build
so that I can experiment with speeding it up

Prior art

  • Ninja generates a logfile
    There are python scripts that can analyze the logfile and convert it to chrome::tracing

https://github.com/ginolatorilla/ninja-log-analyser
https://github.com/nico/ninjatracing

  • Bazel takes an optional --profile arg to build and has a separate command to analyze-profile
    The profile is in the chrome::tracing format and can also be viewed in chrome

https://bazel.build/docs/user-manual#profile

  • cargo recently stabilised --timings flag to generate an html with a graph and some tables

https://blog.rust-lang.org/2022/04/07/Rust-1.60.0.html#cargo---timings

Seems like chrome::tracing is the de-facto industry standard for (build) profiles, so probably best to use that.

I'm just a user but I think it's already built in. If you run, e.g.

$ ../n2/target/release/n2 -C out/mac_debug -d trace
$ wc trace.json
    2892   22285  328224 trace.json

It creates a trace.json Which is openable in chrome://tracing etc.

I think the output might need tweaking a little though because some of the slices seem to be overlapping:
Screen Shot 2022-04-13 at 16 42 02

Oh dang, this output at least used to work, I'm not sure what broke it.

I'm just a user but I think it's already built in. If you run, e.g.

$ ../n2/target/release/n2 -C out/mac_debug -d trace
$ wc trace.json
    2892   22285  328224 trace.json

Thanks for pointing this out, I missed this.

I guess my feature request is slightly different now - it would be great to have an analysis command that can generate actionable suggestions from the tracing file.

I added a similar feature request to cargo, i wonder how many of these suggestions would overlap. The rust/crate specific ones might not be useful for Cpp apart from using a faster linker.
rust-lang/cargo#10542