Would it be reasonable to always set a global :cache-root "~/.shadow-cache/" across all of my projects, to reduce the cold start time? I'm using git worktrees with LLM agents to work on different aspects of the same project, and I'm wondering if having them all share a cache would make things much faster (good!) or cause spooky bugs (boo!). Presumably if there were no tradeoffs to a global cache, the option would be on by default.
absolutely not
well I mean if its just one project doing that fine, but not multiple
but no guarantees that multiple processes writing to the same cache don't mess with each other
so I'd strongly advise against it
Interesting. So the cache is keyed by time or something, not content?
time is the least relevant concern
sha1sum is used for content, but compiler settings pretty much everything else factors in
Thanks for the quick reply, btw. Might be worth mentioning in https://shadow-cljs.github.io/docs/UsersGuide.html#_compiler_cache as I checked there first and my main takeaway was "okay, no weird side-effecting macros" but my codebase doesn't have any of those so I thought it might be workable.
yes, but there is no locking around cache files. so if 2 processes try to write at the same time you might get weird results
and if for any reason the cache key produced by one process doesn't match another they'll always invalidate each other
ah, so you have two cold starts, both processes miss for a specific content-addressed source file, then they both write at the same time and step on each other.
so any cache file also includes the cache keys of its dependencies
if one process modifies file a that some other file b depends on. then an agent working on a automatically invalidates the cache for something else working on b
this is all hard enough to work out for a single process. I don't even want to think about making it safe multi-process
Gotcha. Yeah I was thinking that a content-addressed cache should be workable out-of-the-box for an arbitrary number of processes (as long as the addressing includes the transitive closure of dependencies).
Glad I checked with you first. =D Appreciate the quick reply and all of your work on ShadowCLJS.