bazel

How to run multiple Bazel Query operations in parallel?


I have to perform a few queries for analyzing a set of targets. I tried running them multi-threaded but Bazel still seems to execute them only serially.

I know Bazel in general does not allow parallel execution of work. But I was wondering if there is a way to make query work assuming there is no modification/build happening meanwhile.


Solution

  • You could use separate --output_bases, although that will extract all the external repositories multiple times.

    Depending on your queries, you may be able to use genquery to get the results via a bazel build command. However, the lack of support for wildcards is often problematic.

    Much of the work bazel query does is cached. If you do a big enough query first (even if you discard the results), it should load everything in parallel and then the subsequent ones should be fast.