shadow-cljs

2026-05-12T07:59:36.434049Z

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.

thheller 2026-05-12T07:59:58.973329Z

absolutely not

thheller 2026-05-12T08:00:45.355909Z

well I mean if its just one project doing that fine, but not multiple

thheller 2026-05-12T08:01:07.477129Z

but no guarantees that multiple processes writing to the same cache don't mess with each other

thheller 2026-05-12T08:01:37.244469Z

so I'd strongly advise against it

2026-05-12T08:01:45.571049Z

Interesting. So the cache is keyed by time or something, not content?

thheller 2026-05-12T08:03:14.388939Z

time is the least relevant concern

thheller 2026-05-12T08:03:44.118699Z

sha1sum is used for content, but compiler settings pretty much everything else factors in

2026-05-12T08:03:50.835229Z

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.

thheller 2026-05-12T08:04:30.881349Z

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

thheller 2026-05-12T08:05:21.113359Z

and if for any reason the cache key produced by one process doesn't match another they'll always invalidate each other

2026-05-12T08:05:26.291589Z

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.

thheller 2026-05-12T08:05:50.177069Z

so any cache file also includes the cache keys of its dependencies

thheller 2026-05-12T08:06:34.549449Z

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

thheller 2026-05-12T08:07:08.126579Z

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

2026-05-12T08:09:54.630499Z

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).

2026-05-12T08:10:18.508239Z

Glad I checked with you first. =D Appreciate the quick reply and all of your work on ShadowCLJS.