Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to understand Bazel's output time?

Tags:

bazel

Everytime after a build is done, I see something like:

Elapsed time: 1034.748s, Critical Path: 257.54s

Wondering what's the difference between Elapsed Time and Critical Path? What can be causing the time difference?

Forwarded from: https://github.com/bazelbuild/bazel/issues/3164

like image 465
Yun Peng Avatar asked Jun 12 '17 11:06

Yun Peng


People also ask

How does Bazel build work?

Bazel build process When running a build or a test, Bazel does the following: Loads the BUILD files relevant to the target. Analyzes the inputs and their dependencies, applies the specified build rules, and produces an action graph. Executes the build actions on the inputs until the final build outputs are produced.

What is a Bazel rule?

A rule defines a series of actions that Bazel performs on inputs to produce a set of outputs, which are referenced in providers returned by the rule's implementation function.

Where is Bazel cache stored?

To do so, bazel caches all files downloaded in the repository cache which, by default, is located at ~/. cache/bazel/_bazel_$USER/cache/repos/v1/ . The location can be changed by the --repository_cache option. The cache is shared between all workspaces and installed versions of bazel.


1 Answers

"Elapsed time" shows the wall time of the build, since Bazel started running the first build action until the last action finished.

"Critical path" shows the wall time spent building the longest chain of actions, where each subsequent action depends on the output(s) of the previous one, so they must be run sequentially. The critical path is a lower limit on the clean build time of this build; even if the CPU had more cores than the number of actions Bazel ever runs in parallel, the build could still not complete any faster.

The time difference is caused by Bazel executing other actions too. There were presumably more actions to run than just those on the critical path.

like image 180
László Avatar answered Oct 04 '22 00:10

László