by neilv · 2y ago · 0 comments
Laptops have ridiculously large amounts of RAM nowadays. My Linux laptop setup barely makes a dent in the RAM, even when running 3 different Web browsers and other gluttonous desktop programs. `tmpfs` is a great use for excess RAM, reducing wear on SSD. (I also disable swap.)
I've also done things like build an entire large ecosystem of packages in `tmpfs`, when the build server happened to have mirrored 10krpms drives, and I didn't want the tons of intermediate files to eventually be synced to disk. (Even though, with disk, they would also probably hang around in Linux filesystem buffers, not reads hitting disk each time.)
Edit: du -hc ~/.cache says it's 25G.
I didn't think of the massive ML models, because I store those in the home directory, where I can see them.
(Incidentally, since you mention Stable Diffusion: for an earlier version of SD, I went to some care to make sure I didn't accidentally lose the checkpoint file, because I didn't know whether it would be pulled from distribution. Then there were regressions in the SD training data.)
That works for most things, and that's how it should be. But sometimes the dev just doesn't provide links and you either have to read their code to figure out the model URLs, or simply allow the automatic download that ends up in .cache.
Your average person isn’t running Linux or compiling things. The comment was in the context of developer laptops.
(Well and Yocto builds, but that's not your average 'compiling things'.)
If something is supposed to persist past reboot, I wouldn't put it in `.cache`. Though I don't know offhand what the official documented behavior of `.cache` is, and I can't immediately find that documentation (maybe some open desktop cabal thing?).
> $XDG_CACHE_HOME defines the base directory relative to which user-specific non-essential data files should be stored. If $XDG_CACHE_HOME is either not set or empty, a default equal to $HOME/.cache should be used.
My ~/.cache could be rm -rf'd without too much worry right now, but that doesn't mean that persisting it isn't useful. For example on my system right now:
- Browser cache is useful to persist, especially with some larger sites.
- I put my Go module and build cache in ~/.cache, and while that can be deleted it's useful to persist because it make builds shorter, and avoids having to (re)-download the same modules over and over again. Note that at the moment my internet is kind of crappy so this can take quite a while.
- Some other download cache things in there, from luarocks, xlocate, few other things.
- I store psql history per-database in ~/.cache/psql-dbname. It's useful to keep this around.
- Vim backup files, persistent undo files, and swap files are stored in ~/.vim. The swap files especially are important because I want to keep them after an unexpected system crash.
Some of this is solvable by moving stuff to other directories. Others are inherently unsolvable.
I also have just 8G of RAM, which is fine but not fine for storing ~/.cache in RAM.
It's not going to cause "problems". It's just going to massively slow down many use cases that rely on downloads.