The cache
Every step is cached. A step’s cache key is a hash of everything doris knows can change its result, and a step whose key is already stored is not run again: its outputs and verdict are restored. A second run with nothing changed runs no tool at all.
doris plan FLOW DESIGN # shows which steps would come from the cache
doris run FLOW --rerun # run every selected step anyway, and replace its entry
doris run FLOW --rerun=build,run # run only the steps of these names anyway
doris run FLOW --no-store # take steps from the cache, but store nothing
doris run FLOW --no-cache # run every step, and neither read nor write the cache
--rerun=STEP,... reruns the steps of those names in every selected job, as doris plan names them, and replaces their entries. The steps downstream of them run again only if the new outputs differ, as after any change. A name that no selected job has a step of is an error. The = is needed, so the names are not read as designs.
--no-store reads the cache as usual. A step that runs is not stored: its outputs are hashed, so the steps downstream of it still get keys and can still come from the cache, but nothing is written. --no-cache is --rerun --no-store, and the run has no GC root, as it uses no entry.
The cache is per user, in $XDG_CACHE_HOME/doris, or ~/.cache/doris. It is shared by every checkout and every project, so a second worktree of the same commit starts warm. Cleaning the cache covers how it is kept from growing without limit.
What is in a key
A step’s key is a SHA-256 over:
- the key protocol,
doris-step/2, and the step’s name; - the command: program, arguments, environment variables it sets, working directory, staging, the host variables it asks for, and the programs it declares it runs itself;
- the same for each service, with its name, port name, readiness check and stop rule;
- each tool the step declares: its name, its version as the tool’s probe reports it, such as what
xrun -versionprints, and the hash of the plugin it comes from; - each host variable such a tool names as changing its results: the variable’s name and its value, or that it is not set;
- the content of each declared input;
- the content hash of every output of each step it depends on;
- for a step a plugin runs itself, such as
flattenorinstrument, the plugin’s hash and what the plugin was asked to do; - the names and paths of its own outputs, its accepted exit codes, its pass and fail patterns, the message a failing exit code gives, whether it has a judge, and the output its parse function writes to.
Inputs are hashed as git sees them. A directory input counts its tracked files, plus untracked files that aren’t ignored. Outside a git checkout, or in a directory git ignores entirely, every file counts.
Keys are the same in every checkout. Paths are written relative to the step, the job or the repo root. Port numbers are not part of a key, and neither is anything worked out on the host when a step starts, such as the path of the system libstdc++.
Downstream steps are keyed on output content, not on the upstream key. An edit that reruns a step but leaves its outputs the same reruns nothing after it.
A tool’s version is asked for when a key is worked out, by doris plan and doris run. Each tool is asked once, however many steps use it. The step pages name each step’s key tools and the command that gives the version.
Only one host variable is keyed today: UVM_HOME, for every Verilator build step, because it names the UVM library Verilator compiles. Two machines with the library in different places therefore don’t share that step’s entries.
What is not in a key
A change to any of these does not cause a rerun:
- The inherited environment, other than the variables a tool names as part of its key.
PATH,HOMEandLM_LICENSE_FILEreach every tool and are in no key. - Files a command reads that are not a declared input or an upstream output, such as a simulator’s install, a standard-cell library, or an include file outside the directories doris hashes.
- Programs a command calls that are not among the step’s key tools, such as
z3ormake. The step pages name them. - Timeouts: the step’s own, and its services’ start-up and stop timeouts.
- How a run is carried out:
--debugand every setting, from a file or--set,-jincluded. A step’s prechecks and what it holds from the resource pools are not keyed either.
Three more things can give a result from the cache that a fresh run would not:
- doris’s own part in a result is keyed by the key protocol, not by doris’s version. The protocol is bumped by hand when doris changes how it makes a key, how it reaches a verdict from a step’s rules, or what it does around a plugin’s results, such as writing a linter’s messages to
messages.json. A newer doris that changes none of these keeps the cache. One that changes them without a bump is a bug in doris that would reuse results it should not;--rerunworks around it. A changed plugin is a new hash, so the steps that use its tool rerun. - A tool whose probe fails, because its version command can’t run or exits non-zero, has the version
unknown. It is keyed like any other version, so two versions of a tool whose probe fails share a key. A missing tool is caught by the check before the run, not here. - A judge is keyed by its presence only, and a parse function by its output. What they do is a plugin’s, whose hash is in the key of the step that uses its tool, with doris’s handling around it, which the key protocol covers.
EDA tools are not hermetic, so the cache is only as good as the declared inputs. When in doubt, --rerun.
What is stored
Only passed and failed outcomes are stored. A step error or setup error is never cached, so the step runs again next time.
An entry holds the verdict, its message, and a copy of each declared output. A hit puts the outputs back in the step’s directory, unless they are already there with the same content. Outputs often contain timestamps and paths, so two runs of one step do not give identical bytes. doris caches outputs and never compares them.
Only declared outputs are stored. A step’s stdout.log and stderr.log are in its entry only if the step declares them as outputs, as lint does. A passed step’s other files are deleted when it ends (see Working directories).
Debug outputs are stored by a debug run only. A step can mark an output as a debug output: a file only of use for looking into the step, such as Xcelium’s build.log. A plain run does not store it. doris run --debug does, and its entries say so. A debug run does not take a step from an entry stored without debug outputs: it runs the step and replaces the entry. A plain run takes a step from either kind. Debug outputs are not part of any key, so the two kinds of run share every key and everything downstream.
A step that runs after a failure is cached like any other. TestRIG’s coverage step is keyed on the run step’s outputs whether that passed or failed, since a failed step’s outputs are stored too.
A stored failure keeps its message with the paths made neutral, and a hit shows them as they are in this checkout.
An entry that can’t be read is treated as a miss, without a warning: the step runs and replaces it. An entry that can’t be restored is not an error either. doris warns, runs the step and replaces the entry.
Seeing what was cached
In a job’s result.json, each step has cached and its key. cached: true means the step did not run in this job: its outputs and verdict are those of an earlier run with the same key, and seconds is the time taken to restore them. Any log in its directory is from that earlier run too.
jq -r '.steps[] | "\(.name)\t\(.outcome)\t\(.seconds)s\tcached=\(.cached)"' result.json
Randomised steps
A step that generates its own stimulus from a seed is cached like any other, because the seed is an argument and so part of the key. TestRIG’s generate mode works this way: a run with a seed it has had before comes from the cache, and a run with a newly picked seed always runs. See Generate and replay.
Two steps with the same key
A result is reused whenever two steps have the same key: the same command, inputs and tool versions. That is true across checkouts and across jobs. Steps of different flows that happen to share a name, such as filelist, usually ask for different things and so have different keys.