> ## Documentation Index
> Fetch the complete documentation index at: https://site.aspect.build/llms.txt
> Use this file to discover all available pages before exploring further.

# Determinism: Preventing cache misses

> Learn how Bazel determinism prevents cascading cache misses on CI, and how to diagnose and repair non-hermetic actions that stamp variable data.

The DevInfra team must ensure that CI remains fast by avoiding any unneeded work.
Monitor your cache hit rate and be vigilant about repairing regressions.

For example, someone introduces a `protoc` plugin that stamps a date into the output.
This is non-deterministic and means that the files produced will be different on each build,
so anything (transitively) depending on them will be a cache miss.

Non-determinism higher in the build graph causes more cascading cache misses and should be addressed first.

<Note>
  Remote Build Execution is sometimes sold as a solution, because it spreads the work over many machines, but if the work is unneeded this is the wrong solution because costs are excessive.
  The best answer is simply “less execution”.
</Note>

To locate non-determinisms, there are a few approaches:

1. Run two builds, collecting the `--execution_log_binary_file`.
   Ideally these builds are on different machines but at the same VCS snapshot.
2. Run `bazel dump --action_cache` and see if the `digestKey` matches expectations.
3. <Icon icon="https://mintcdn.com/aspectbuild/gtqBKXWWd-jWHweY/logo/icon.png?fit=max&auto=format&n=gtqBKXWWd-jWHweY&q=85&s=0639e7d5498c5c9cd0924dbe51dc7653" size={20} width="144" height="128" data-path="logo/icon.png" /> The Aspect CLI has an `explain` command. When run with the `--cache-misses` flag, it compares two “compact” execution logs, looking for non-determinism by analyzing:
   * Actions: Changed outputs, timing, or ordering
   * Files: Unexpected file modifications
   * Environment: Non-hermetic environment variables
   * Arguments: Inconsistent build flags

<Callout icon="book">
  Read more:

  * [diagnose cache misses 1](/blog/diagnose-cache-misses-1)
  * [npm determinism](/blog/npm-determinism)
  * [https://bazel.build/remote/cache-remote#troubleshooting-cache-hits](https://bazel.build/remote/cache-remote#troubleshooting-cache-hits)
</Callout>
