make any crate that includes foo_api take 2.5s to compile
I am getting no insights from "cargo llvm-lines"
Question: what other commands can I run to get intuition on why the $#(# this crate is slow to compile (and why it slows down everything that includes it?)
My suspicion: something to do with generic generating code that is thrown away at linker time.
There's a fasterthanlime article about profiling builds that might find you some clues. One gotcha when I tested it locally - if you're in a workspace, the profile data gets saved to the workspace root, not the package root. And note that if you don't use a Chromium-based browser, Perfetto provides the same UI as a web application instead of built-in to your browser.
If you convert to Chrome format and use -Z self-profile-events=all, you should get more detail (IIUC). I don't have a complex crate easily to hand to test on (I used my quick-and-dirty Advent of Code workspace for the initial testing), but it should give you more details in "Arguments" when you click on a slow slice.
This is very helpful and I'm grateful for you sharing.
I have 1 last problem: crox seems to show total runtime at ~300ms, whereas cargo build --timings shows it at 1.5-1.8s. There seems to be a 5-6x difference in measured time. Have you run into this issue ?
I'm afraid I only ever needed to look at relative numbers, not absolute; when I've used it before, I was using it to track down something that had gone from taking a few seconds to taking 5 minutes (roughly) to build, and once I'd found the macro whose expansion was supralinear in its input and fixed it, I was done.
On my phone right now, so can't test this: Does those timing include the final link time? Are you on a weird os (i.e. Windows) with some intrusive services (i.e. antivirus) running that could be throwing things off?
How do I test this? I could never figure out compile vs link on cargo build --timings. In a workspace, does link time hit anything other than the last/final/root crate? (This is an intermediate crate.)
I am on nixos linux, target wasm32-unknown-unknown. AFAIK nothing else (besides Chrome + IntelliJ Idea) is running.