Skip to content

Commit 4fa4f8a

Browse files
vtjnashKristofferC
authored andcommitted
loading: improve precompilation cache reason messages (#60012)
Make cache invalidation reason messages clearer and more user-friendly by removing abbreviations and using more positive, informative language. Changes include: - Expanded all abbreviations (e.g., "dep" → "dependency", "fsize" → "file size") - Replaced negative-sounding terms like "wrong" with neutral "different" - Made technical terms clearer (e.g., "ocachefile" → "native code cache file") - Changed "cache misses" to "caches not reused" for more positive framing - Reordered format from "reason (count)" to "count for reason" for better readability Fixes #59255 🤖 Generated with Claude Code (cherry picked from commit bfa0e4d)
1 parent 9df3c83 commit 4fa4f8a

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

base/loading.jl

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4018,7 +4018,7 @@ end
40184018
record_reason(::Nothing, ::String) = nothing
40194019
function list_reasons(reasons::Dict{String,Int})
40204020
isempty(reasons) && return ""
4021-
return " (cache misses: $(join(("$k ($v)" for (k,v) in reasons), ", ")))"
4021+
return " (caches not reused: $(join(("$v for $k" for (k,v) in reasons), ", ")))"
40224022
end
40234023
list_reasons(::Nothing) = ""
40244024

@@ -4027,7 +4027,7 @@ function any_includes_stale(includes::Vector{CacheHeaderIncludes}, cachefile::St
40274027
f, fsize_req, hash_req, ftime_req = chi.filename, chi.fsize, chi.hash, chi.mtime
40284028
if startswith(f, string("@depot", Filesystem.pathsep()))
40294029
@debug("Rejecting stale cache file $cachefile because its depot could not be resolved")
4030-
record_reason(reasons, "nonresolveable depot")
4030+
record_reason(reasons, "file location uses unresolved depot path")
40314031
return true
40324032
end
40334033
if !ispath(f)
@@ -4036,7 +4036,7 @@ function any_includes_stale(includes::Vector{CacheHeaderIncludes}, cachefile::St
40364036
continue
40374037
end
40384038
@debug "Rejecting stale cache file $cachefile because file $f does not exist"
4039-
record_reason(reasons, "missing sourcefile")
4039+
record_reason(reasons, "source file not found")
40404040
return true
40414041
end
40424042
if ftime_req >= 0.0
@@ -4050,21 +4050,21 @@ function any_includes_stale(includes::Vector{CacheHeaderIncludes}, cachefile::St
40504050
!( 0 < (ftime_req - ftime) < 1e-6 ) # PR #45552: Compensate for Windows tar giving mtimes that may be incorrect by up to one microsecond
40514051
if is_stale
40524052
@debug "Rejecting stale cache file $cachefile because mtime of include_dependency $f has changed (mtime $ftime, before $ftime_req)"
4053-
record_reason(reasons, "include_dependency mtime change")
4053+
record_reason(reasons, "file modification time changed")
40544054
return true
40554055
end
40564056
else
40574057
fstat = stat(f)
40584058
fsize = filesize(fstat)
40594059
if fsize != fsize_req
40604060
@debug "Rejecting stale cache file $cachefile because file size of $f has changed (file size $fsize, before $fsize_req)"
4061-
record_reason(reasons, "include_dependency fsize change")
4061+
record_reason(reasons, "file size changed")
40624062
return true
40634063
end
40644064
hash = isdir(fstat) ? _crc32c(join(readdir(f))) : open(_crc32c, f, "r")
40654065
if hash != hash_req
40664066
@debug "Rejecting stale cache file $cachefile because hash of $f has changed (hash $hash, before $hash_req)"
4067-
record_reason(reasons, "include_dependency fhash change")
4067+
record_reason(reasons, "file content changed")
40684068
return true
40694069
end
40704070
end
@@ -4092,7 +4092,7 @@ end
40924092
checksum = isvalid_cache_header(io)
40934093
if iszero(checksum)
40944094
@debug "Rejecting cache file $cachefile due to it containing an incompatible cache header"
4095-
record_reason(reasons, "incompatible header")
4095+
record_reason(reasons, "different Julia build configuration")
40964096
return true # incompatible cache file
40974097
end
40984098
modules, (includes, _, requires), required_modules, srctextpos, prefs, prefs_hash, clone_targets, actual_flags = parse_cache_header(io, cachefile)
@@ -4105,7 +4105,7 @@ end
41054105
requested flags: $(requested_flags) [$(_cacheflag_to_uint8(requested_flags))]
41064106
cache file: $(CacheFlags(actual_flags)) [$actual_flags]
41074107
"""
4108-
record_reason(reasons, "mismatched flags")
4108+
record_reason(reasons, "different compilation options")
41094109
return true
41104110
end
41114111
pkgimage = !isempty(clone_targets)
@@ -4114,7 +4114,7 @@ end
41144114
if JLOptions().use_pkgimages == 0
41154115
# presence of clone_targets means native code cache
41164116
@debug "Rejecting cache file $cachefile for $modkey since it would require usage of pkgimage"
4117-
record_reason(reasons, "requires pkgimages")
4117+
record_reason(reasons, "native code caching disabled")
41184118
return true
41194119
end
41204120
rejection_reasons = check_clone_targets(clone_targets)
@@ -4123,12 +4123,12 @@ end
41234123
Reasons=rejection_reasons,
41244124
var"Image Targets"=parse_image_targets(clone_targets),
41254125
var"Current Targets"=current_image_targets())
4126-
record_reason(reasons, "target mismatch")
4126+
record_reason(reasons, "different system or CPU target")
41274127
return true
41284128
end
41294129
if !isfile(ocachefile)
41304130
@debug "Rejecting cache file $cachefile for $modkey since pkgimage $ocachefile was not found"
4131-
record_reason(reasons, "missing ocachefile")
4131+
record_reason(reasons, "native code cache file not found")
41324132
return true
41334133
end
41344134
else
@@ -4137,15 +4137,15 @@ end
41374137
id = first(modules)
41384138
if id.first != modkey && modkey != PkgId("")
41394139
@debug "Rejecting cache file $cachefile for $modkey since it is for $id instead"
4140-
record_reason(reasons, "for different pkgid")
4140+
record_reason(reasons, "different package identifier")
41414141
return true
41424142
end
41434143
id_build = id.second
41444144
id_build = (UInt128(checksum) << 64) | (id_build % UInt64)
41454145
if build_id != UInt128(0)
41464146
if id_build != build_id
41474147
@debug "Ignoring cache file $cachefile for $modkey ($(UUID(id_build))) since it does not provide desired build_id ($((UUID(build_id))))"
4148-
record_reason(reasons, "for different buildid")
4148+
record_reason(reasons, "different build identifier")
41494149
return true
41504150
end
41514151
end
@@ -4171,20 +4171,20 @@ end
41714171
continue
41724172
elseif M == Core
41734173
@debug "Rejecting cache file $cachefile because it was made with a different julia version"
4174-
record_reason(reasons, "wrong julia version")
4174+
record_reason(reasons, "different Julia version")
41754175
return true # Won't be able to fulfill dependency
41764176
elseif ignore_loaded || !stalecheck
41774177
# Used by Pkg.precompile given that there it's ok to precompile different versions of loaded packages
41784178
else
41794179
@debug "Rejecting cache file $cachefile because module $req_key is already loaded and incompatible."
4180-
record_reason(reasons, "wrong dep version loaded")
4180+
record_reason(reasons, "different dependency version already loaded")
41814181
return true # Won't be able to fulfill dependency
41824182
end
41834183
end
41844184
path = locate_package(req_key) # TODO: add env and/or skip this when stalecheck is false
41854185
if path === nothing
41864186
@debug "Rejecting cache file $cachefile because dependency $req_key not found."
4187-
record_reason(reasons, "dep missing source")
4187+
record_reason(reasons, "dependency source file not found")
41884188
return true # Won't be able to fulfill dependency
41894189
end
41904190
depmods[i] = (path, req_key, req_build_id)
@@ -4203,7 +4203,7 @@ end
42034203
break
42044204
end
42054205
@debug "Rejecting cache file $cachefile because it provides the wrong build_id (got $((UUID(build_id)))) for $req_key (want $(UUID(req_build_id)))"
4206-
record_reason(reasons, "wrong dep buildid")
4206+
record_reason(reasons, "different dependency build identifier")
42074207
return true # cachefile doesn't provide the required version of the dependency
42084208
end
42094209
end
@@ -4219,7 +4219,7 @@ end
42194219
if !(isreadable(stdlib_path) && samefile(stdlib_path, modpath))
42204220
!samefile(fixup_stdlib_path(includes[1].filename), modpath)
42214221
@debug "Rejecting cache file $cachefile because it is for file $(includes[1].filename) not file $modpath"
4222-
record_reason(reasons, "wrong source")
4222+
record_reason(reasons, "different source file path")
42234223
return true # cache file was compiled from a different path
42244224
end
42254225
end
@@ -4228,7 +4228,7 @@ end
42284228
pkg = identify_package(modkey, req_modkey.name)
42294229
if pkg != req_modkey
42304230
@debug "Rejecting cache file $cachefile because uuid mapping for $modkey => $req_modkey has changed, expected $modkey => $(repr("text/plain", pkg))"
4231-
record_reason(reasons, "dep uuid changed")
4231+
record_reason(reasons, "dependency identifier changed")
42324232
return true
42334233
end
42344234
end
@@ -4239,22 +4239,22 @@ end
42394239

42404240
if !isvalid_file_crc(io)
42414241
@debug "Rejecting cache file $cachefile because it has an invalid checksum"
4242-
record_reason(reasons, "invalid checksum")
4242+
record_reason(reasons, "cache file checksum is invalid")
42434243
return true
42444244
end
42454245

42464246
if pkgimage
42474247
if !isvalid_pkgimage_crc(io, ocachefile::String)
42484248
@debug "Rejecting cache file $cachefile because $ocachefile has an invalid checksum"
4249-
record_reason(reasons, "ocachefile invalid checksum")
4249+
record_reason(reasons, "native code cache checksum is invalid")
42504250
return true
42514251
end
42524252
end
42534253

42544254
curr_prefs_hash = get_preferences_hash(id.uuid, prefs)
42554255
if prefs_hash != curr_prefs_hash
42564256
@debug "Rejecting cache file $cachefile because preferences hash does not match 0x$(string(prefs_hash, base=16)) != 0x$(string(curr_prefs_hash, base=16))"
4257-
record_reason(reasons, "preferences hash mismatch")
4257+
record_reason(reasons, "package preferences changed")
42584258
return true
42594259
end
42604260

0 commit comments

Comments
 (0)