Cache and results
doris keeps two kinds of thing: cache entries, which let a step be skipped, and result files, which are the record of a job. This page gives the reasons behind each. The cache, Cleaning the cache and Results and reports say how to use them.
Cache keys
Every step of a job is cached by itself. Its key is a hash of what doris knows can change its result: the command and its services, the versions of the tools it declares, the content of its inputs, and the content of its upstream steps’ outputs. What is in a key has the full list.
- A key holds nothing tied to one machine. Paths are written relative to the step’s directory, the job’s directory or the repo root, so a key is the same in every checkout. Port numbers, and anything worked out on the host when a step starts, are left out.
- The environment is keyed by inclusion. A tool is given the whole host environment, but only what its invocation sets or asks for, and the variables the tool names as its
key_env, are part of the key. Keying on everything would let any unrelated variable invalidate the cache, and no two machines or users share an environment. The cost is that a variable that changes results without being declared gives a stale hit. - A
key_envvariable is keyed by its value, or as not set. It is the one thing in a key that is read from the host besides tool versions, so a tool names a variable only when it changes what the tool writes. Verilator as a simulator namesUVM_HOME. - A tool is identified by its version string, which its
probereports. Its install path would tie keys to one machine, and installs are too large to hash. A probe that fails gives the versionunknown. - A tool’s plugin is identified by its hash. The plugin decides the command, judges the step and reads its logs, so a new plugin is a new key for every step that uses its tool (see Tool plugins).
- Downstream steps are keyed on output content, not on the upstream key. A change that reruns a step but leaves its outputs the same reruns nothing after it.
- An in-process step is keyed on its parameters. Every in-process step is a plugin’s callback, keyed by its data, which is all the plugin is given, and by the plugin’s hash, as
Step::params hashed with paths made neutral:flatten’s holds the file-list format and top module, andinstrument’s its coverage scopes and waves top. Without them a change to one could be a stale hit. - Inputs are hashed as git sees them: tracked files, plus untracked files that aren’t ignored. Build products lying in the repo don’t change a key.
- How a run is carried out is not keyed.
-j,--debug, timeouts, prechecks, the sizes of resource pools and thegc.*,dirs.*andtools.*settings never change a result, so changing them invalidates nothing.
Only passed and failed are stored. A step error or setup error says nothing about the design, so the step runs again next time.
Cache entries
An entry holds the step’s verdict, a copy of each output, and the keys of the entries it was built from.
- Debug outputs are stored apart from the others. An entry has
debug, whether a run with--debugstored it, anddebug_outputs, the hashes of the debug outputs it then has.outputsnever lists a debug output, and onlyoutputsfeed downstream keys. So a debug run and a plain run agree on every key, and an entry either kind stores serves the steps after it in both. - A debug run does not use an entry stored without debug outputs. The debug outputs would be missing, so the step runs again and its entry is replaced by one that has them. A plain run uses either kind of entry.
- The entry format did not change name. Both fields default when absent, so an entry written before they existed is read as one stored by a plain run. The schema is still
doris/cache-entry/1. - A cache unit has one entry, for the unit. Its key holds the key of each child, worked out with no upstream outputs, and the children each child runs after. Its outputs are the unit’s exports. A child has no entry of its own, and the journal that resumes an interrupted unit is never stored. See Cache units.
Two steps with the same key share an entry, across jobs, checkouts and projects. This is how a shared design used by two tops is built once, and how the simulators of one TestRIG design share the model and engine builds.
EDA tools are not hermetic, so the cache is only as good as the declared inputs. What is not in a key lists the gaps.
GC roots
The cache is per user and shared by every checkout, so no one run knows what can be deleted. Collection follows Nix generations: every run writes a root naming the entries it used, each entry names the entries it was built from, and a collection deletes what no root reaches.
- A root is the record of a run. It holds the command line, the revision, the jobs, and each job’s result file, so the report of a past run can be made for as long as its root lives.
- The newest root of each job on each branch is kept, whatever its age, so a branch left for a month still has a warm cache.
- A pin protects a root that must be kept, such as a sign-off run.
Result files
Each flow has its own result format with a versioned schema, such as dv/lint-result/1, defined by the Rust types that write it. The metadata every flow shares follows the lowrisc-dv-evidence format, so other tools that read that format see the same fields.
- A result file is read by its
schema. A change old readers would misread gets a new version. Result files outlive the doris that wrote them. - A result is written from step outcomes and declared outputs, so it is the same whether a step ran or came from the cache, and whatever was cleaned from the step’s directory.
- A cache unit is one step in a result. Its children are not listed.
- A report is made from result files only, never from logs or step directories. A page is not a record: it is made again whenever it is asked for, by the doris that is asked.
Names on disk
Config and result schemas use the neutral dv/ prefix, because other tools read them. Cache entries and GC roots are doris’s own and use doris/. The formats are documented where users meet them: config files, result files and the cache directory.
Not built
The roadmap’s Cache page has keys on the build of doris, a file index, include files, content-addressed blobs and a shared cache. Results has tool versions in the reports, published schemas and Markdown reports.