Add an execution log differ that reports why spawns differ between two builds

Open
#33,147 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
java

Research direction

Start by reading src/tools/execlog:parser and the documented execution log comparison procedure linked in the issue. The proposal describes matching spawns and tracing changed inputs through the spawn graph, but the implementation is not included in the issue, and the author says it is about 1,000 lines of Java plus unit tests. Done means a tool in src/tools/execlog that compares compact logs and reports root causes with affected spawn counts.

Written by the indexing model from the issue text.

Description

team-Performance team-Remote-Exec type: feature request untriaged
Description of the feature request:

Add a tool next to //src/tools/execlog:parser that compares two compact execution logs of the same build and reports why spawns differ, grouped by root cause.

One changed env var or source file makes every downstream spawn differ. The tool reports only the differences that aren't a consequence of another spawn, with the number of spawns each one affects. Output for two builds of a six-genrule workspace, where I edited a.txt between the builds and one genrule writes $RANDOM:

Spawns: 6 before, 6 after
Matched: 1 identical, 5 different
Unmatched: 0 only before, 0 only after

Causes, by the number of matched spawns that differ because of them:

1. file: a.txt
   3 spawns taking 0.056s, first: Genrule bazel-out/darwin_arm64-fastbuild/bin/a.out [//:a]

2. nondeterministic spawn: Genrule bazel-out/darwin_arm64-fastbuild/bin/stamp.out [//:stamp]
   2 spawns taking 0.037s, first: Genrule bazel-out/darwin_arm64-fastbuild/bin/stamp.out [//:stamp]

It detects changed arguments, env vars, platform properties and timeouts, added or removed inputs, changed files that no spawn in the log produces, and spawns that produce different outputs from the same command and inputs.

I have an implementation with unit tests and can send a PR if this is welcome in the tree.

Which category does this issue belong to?

Remote Execution

What underlying problem are you trying to solve with this feature?

Debugging cache misses between two builds.

The documented procedure is to build the parser from source, convert both logs to text and diff them. On a large build that diff is mostly consequences: the one difference that matters is repeated in every spawn downstream of it, and a nondeterministic action looks the same as one whose inputs changed.

--verbose_explanations became a no-op in ec10da4e3fad, whose description points to the execution log as the better way to pinpoint why an action was re-run. I couldn't find tooling on top of the log that does this.

Which operating system are you running Bazel on?

macOS

What is the output of bazel info release?

release 9.3.3

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

Have you found anything relevant by searching the web?
  • scripts/aquery_differ compares command lines and input lists from two aquery outputs. It has no digests or outputs, so it can't see changed file contents or nondeterminism.
  • #24071 is about noise in the textual diff of two parsed logs.
  • #7962 and #32027 hash targets to tell that something changed, not why.
Any other information, logs, or outputs that you want to share?

Implementation notes:

  • It reads the compact format directly and keeps input sets nested. Sets are compared by a hash computed while reading and only flattened for spawns whose set of input paths changed.
  • Spawns are matched by mnemonic and first output.
  • A changed input is attributed to the spawn that produced it, through symlink actions and output directories, so causes propagate along the spawn graph.

Limits: compact format only, text output only, and builds with different output directories don't match up.

Is src/tools/execlog the right place for this? I could follow up with JSON output and a non-zero exit code on nondeterminism for use in CI.

The implementation is about 1,000 lines of Java plus unit tests, all under src/tools/execlog with no changes to Bazel itself; comparing two logs of a 966-spawn build of //src/tools/execlog:parser takes 0.7 s and peaks at 250 MB.

Dominant language
Java
Stars
26.2k
Forks
4.7k
Avg merge
3d 11h
Merged PRs (30d)
125

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bazelbuild/bazel

All issues in bazelbuild/bazel

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.