@@ -350,9 +350,49 @@ The `-Ztimings` flag can optionally take a comma-separated list of the
350350following values:
351351
352352- ` html ` — Saves a file called ` cargo-timing.html ` to the current directory
353- with a report of the compilation.
353+ with a report of the compilation. Files are also saved with a timestamp in
354+ the filename if you want to look at older runs.
354355- ` info ` — Displays a message to stdout after each compilation finishes with
355356 how long it took.
356357- ` json ` — Emits some JSON information about timing information.
357358
358359The default if none are specified is ` html,info ` .
360+
361+ #### Reading the graphs
362+
363+ There are two graphs in the output. The "unit" graph shows the duration of
364+ each unit over time. A "unit" is a single compiler invocation. There are lines
365+ that show which additional units are "unlocked" when a unit finishes. That is,
366+ it shows the new units that are now allowed to run because their dependencies
367+ are all finished. Hover the mouse over a unit to highlight the lines. This can
368+ help visualize the critical path of dependencies. This may change between runs
369+ because the units may finish in different orders.
370+
371+ The "codegen" times are highlighted in a lavender color. In some cases, build
372+ pipelining allows units to start when their dependencies are performing code
373+ generation. This information is not always displayed (for example, binary
374+ units do not show when code generation starts).
375+
376+ The "custom build" units are ` build.rs ` scripts, which when run are
377+ highlighted in orange.
378+
379+ The second graph shows Cargo's concurrency over time. The three lines are:
380+ - "Waiting" (red) — This is the number of units waiting for a CPU slot to
381+ open.
382+ - "Inactive" (blue) — This is the number of units that are waiting for their
383+ dependencies to finish.
384+ - "Active" (green) — This is the number of units currently running.
385+
386+ Note: This does not show the concurrency in the compiler itself. ` rustc `
387+ coordinates with Cargo via the "job server" to stay within the concurrency
388+ limit. This currently mostly applies to the code generation phase.
389+
390+ Tips for addressing compile times:
391+ - Look for slow dependencies.
392+ - Check if they have features that you may wish to consider disabling.
393+ - Consider trying to remove the dependency completely.
394+ - Look for a crate being built multiple times with different versions. Try to
395+ remove the older versions from the dependency graph.
396+ - Split large crates into smaller pieces.
397+ - If there are a large number of crates bottlenecked on a single crate, focus
398+ your attention on improving that one crate to improve parallelism.
0 commit comments