How to reuse julia compiled cache across machines?

Hello,

I’d like to cache the julia package compilation in an external volume which can be read and written to by multiple clients (using a respective kubernetes volume) .

My question is whether it is enough to bring the .julia/compile folder to this special volume, or whether something else, e.g. if the lockfile resides somewhere else, needs to be brought there too.

Thanks to the following two julia additions I hope this works in principle since 1.10

2 Likes

It should just work as you describe.

1 Like

Modulo different CPU architectures across the clients. You might want to set JULIA_CPU_TARGET appropriately

4 Likes

thanks for the hint :+1:

I tried this now but experience recompilation despite the compiled directory being reconstructed. I guess another directory is needed somehow for caching compilation to work…

Does someone know which other package is needed? Or how to debug?

It seems that it is due to mtime changes inside .julia/packages looking into the code it seems that in principle julia has different ways of caching

the mtime way is only one, the other being hash based, which would be better here for central caching.

Does someone know what needs to be set/available for precompilation to use hash for identification?

EDIT: I think I understood that just some packages specify explicitly to use mtime instead of hash by specifying include_dependency("myexternal.file", track_content=false). Hence it is indeed necessary to also backup the packages subdirectory for caching to work.

This should work better in Julia 1.11 (not yet released), for example because of Avoid repeated precompilation when loading from non-relocatable cachefiles by fatteneder · Pull Request #53905 · JuliaLang/julia · GitHub .

2 Likes

To load the caches you need compiled and packages.

Hash identification only works with 1.11 onwards, and that is needed to allow moving the compiled folder.

To debug re-precompilation issues run Julia with the environment variable JULIA_DEBUG=loading.

include_dependency("myexternal.file", track_content=true) is now the default.

Here are some notes on how to relocate pkgs on 1.11: PSA: Cache relocation with Julia v1.11 - HackMD

3 Likes

I know tried to symlink the compiled folder, which works, and also the packages folder to a cache directory, which unfortunately kind of does not work.
It makes julia being super super super slow, like almost not responsive. Not sure what is going on…

EDIT: I think it is not because of the symlink but because of some characteristics of my remote filesystem which is not fully posix compliant or maybe slow for some things.