Skip to content

Bazel query silently thrashes the analysis cache #10902

@kastiglione

Description

@kastiglione

Description of the problem / feature request:

bazel query invalidates the analysis cache for subsequent builds, and neither the output of bazel build nor bazel query indicate the problem.

The best solution would be to call bazel query in a way that uses and preserves the current analysis cache. A secondary solution is to have one or both commands log about the problem.

bazel build does output a message to say that the analysis cache is being discarded – when build flags are changed. However bazel query is silently causing discarding the analysis cache, so we didn't know this was happening.

Chrome traces were showing over 10s of overhead at the start of each build, and we didn't know why. Removing our use of bazel query between builds solved this problem.

Feature requests: what underlying problem are you trying to solve with this feature?

Allow bazel query to reuse and preserve the analysis cache from the recent bazel build, if applicable.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

  1. Do a build
  2. Change a file
  3. Do the same build again

In the second build, the output should say:

INFO: Analyzed target //package:target (0 packages loaded, 0 targets configured).

Now, to see the bug:

  1. Do a build
  2. Do a bazel query
  3. Change a file
  4. Do the same build again

In the second build, the output will show that bazel has had to load >0 packages and configure >0 targets.

What operating system are you running Bazel on?

macOS

What's the output of bazel info release?

release 2.1.0

Metadata

Metadata

Assignees

Labels

P2We'll consider working on this in future. (Assignee optional)not staleIssues or PRs that are inactive but not considered staleteam-Configurabilityplatforms, toolchains, cquery, select(), config transitionstype: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions