From 07f052573a41986d20b340ee3a3b5242e1b9041b Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Thu, 22 Jun 2023 17:20:10 +0100 Subject: [PATCH] Tweak cache pidlocking pt. 2 (#50254) --- base/loading.jl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/base/loading.jl b/base/loading.jl index 4aefa9a08a210..1262872ffaf72 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -2226,14 +2226,14 @@ function compilecache_dir(pkg::PkgId) return joinpath(DEPOT_PATH[1], entrypath) end -function compilecache_path(pkg::PkgId, prefs_hash::UInt64)::String +function compilecache_path(pkg::PkgId, prefs_hash::UInt64; project::String=something(Base.active_project(), ""))::String entrypath, entryfile = cache_file_entry(pkg) cachepath = joinpath(DEPOT_PATH[1], entrypath) isdir(cachepath) || mkpath(cachepath) if pkg.uuid === nothing abspath(cachepath, entryfile) * ".ji" else - crc = _crc32c(something(Base.active_project(), "")) + crc = _crc32c(project) crc = _crc32c(unsafe_string(JLOptions().image_file), crc) crc = _crc32c(unsafe_string(JLOptions().julia_bin), crc) crc = _crc32c(ccall(:jl_cache_flags, UInt8, ()), crc) @@ -2823,17 +2823,17 @@ global mkpidlock_hook global trymkpidlock_hook global parse_pidfile_hook -# The preferences hash is only known after precompilation so just assume no preferences -# meaning that if all other conditions are equal, the same package cannot be precompiled -# with different preferences at the same time. -compilecache_pidfile_path(pkg::PkgId) = compilecache_path(pkg, UInt64(0)) * ".pidfile" +# The preferences hash is only known after precompilation so just assume no preferences. +# Also ignore the active project, which means that if all other conditions are equal, +# the same package cannot be precompiled from different projects and/or different preferences at the same time. +compilecache_pidfile_path(pkg::PkgId) = compilecache_path(pkg, UInt64(0); project="") * ".pidfile" # Allows processes to wait if another process is precompiling a given source already. # The lock file is deleted and precompilation will proceed after `stale_age` seconds if # - the locking process no longer exists # - the lock is held by another host, since processes cannot be checked remotely -# or after `stale_age * 25` seconds if it does still exist. -function maybe_cachefile_lock(f, pkg::PkgId, srcpath::String; stale_age=60) +# or after `stale_age * 25` seconds if the process does still exist. +function maybe_cachefile_lock(f, pkg::PkgId, srcpath::String; stale_age=300) if @isdefined(mkpidlock_hook) && @isdefined(trymkpidlock_hook) && @isdefined(parse_pidfile_hook) pidfile = compilecache_pidfile_path(pkg) cachefile = invokelatest(trymkpidlock_hook, f, pidfile; stale_age)