Caching Strategy
FZ caches results by the MD5 hash of a case's input files. A
cache:// calculator reuses a previous result whenever the
input hashes match and the stored outputs are valid — no recomputation.
Matching is by .fz_hash content, so it is independent of the
case_naming scheme used to
write the cache.
Strategies
Resume an interrupted run
fz.fzr("input.txt", {"param": list(range(100))}, model,
"sh://bash slow_calc.sh", results_dir="run1")
# interrupted with Ctrl+C after ~50 cases
fz.fzr("input.txt", {"param": list(range(100))}, model,
["cache://run1", "sh://bash slow_calc.sh"], results_dir="run1_resumed")
Expand the parameter space
fz.fzr("input.txt", {"temp": [100, 200, 300], "pressure": [1, 10, 100]}, model,
"sh://bash calc.sh", results_dir="study1") # 9 cases
fz.fzr("input.txt",
{"temp": [100, 200, 300, 400, 500], "pressure": [1, 10, 100, 1000, 10000]},
model, ["cache://study1", "sh://bash calc.sh"], results_dir="study2") # reuses 9, runs 16
Multi-tier cache
calculators = [
"cache://latest_run",
"cache://archive/2024-*",
"cache://archive/*/*",
"sh://bash calc.sh", # last resort
]
What the Cache Keys On
Only the input files. It does not consider the calculator command, so:
- Changing the calculation script but not the inputs → still a cache hit.
- To force recomputation, run into a fresh
results_dirwith nocache://entry.
fzd Caching
fzd adds two automatic layers on top:
- Cross-iteration caching — a point evaluated in one iteration is never re-run in a later one.
- Re-run resume — an existing
analysis_diris renamed with a timestamp and its iteration directories are added to the cache, so a re-run reuses all prior work.
Housekeeping
# Drop result payloads older than 30 days but keep the cache keys
find results/ -type d -mtime +30 -exec rm -rf {} +
find results/ -type f ! -name '.fz_hash' -delete