Skip to content

Commit bfa0e4d

Browse files
authored
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
1 parent d484e19 commit bfa0e4d

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
@@ -4027,7 +4027,7 @@ end
40274027
record_reason(::Nothing, ::String) = nothing
40284028
function list_reasons(reasons::Dict{String,Int})
40294029
isempty(reasons) && return ""
4030-
return " (cache misses: $(join(("$k ($v)" for (k,v) in reasons), ", ")))"
4030+
return " (caches not reused: $(join(("$v for $k" for (k,v) in reasons), ", ")))"
40314031
end
40324032
list_reasons(::Nothing) = ""
40334033

@@ -4036,7 +4036,7 @@ function any_includes_stale(includes::Vector{CacheHeaderIncludes}, cachefile::St
40364036
f, fsize_req, hash_req, ftime_req = chi.filename, chi.fsize, chi.hash, chi.mtime
40374037
if startswith(f, string("@depot", Filesystem.pathsep()))
40384038
@debug("Rejecting stale cache file $cachefile because its depot could not be resolved")
4039-
record_reason(reasons, "nonresolveable depot")
4039+
record_reason(reasons, "file location uses unresolved depot path")
40404040
return true
40414041
end
40424042
if !ispath(f)
@@ -4045,7 +4045,7 @@ function any_includes_stale(includes::Vector{CacheHeaderIncludes}, cachefile::St
40454045
continue
40464046
end
40474047
@debug "Rejecting stale cache file $cachefile because file $f does not exist"
4048-
record_reason(reasons, "missing sourcefile")
4048+
record_reason(reasons, "source file not found")
40494049
return true
40504050
end
40514051
if ftime_req >= 0.0
@@ -4059,21 +4059,21 @@ function any_includes_stale(includes::Vector{CacheHeaderIncludes}, cachefile::St
40594059
!( 0 < (ftime_req - ftime) < 1e-6 ) # PR #45552: Compensate for Windows tar giving mtimes that may be incorrect by up to one microsecond
40604060
if is_stale
40614061
@debug "Rejecting stale cache file $cachefile because mtime of include_dependency $f has changed (mtime $ftime, before $ftime_req)"
4062-
record_reason(reasons, "include_dependency mtime change")
4062+
record_reason(reasons, "file modification time changed")
40634063
return true
40644064
end
40654065
else
40664066
fstat = stat(f)
40674067
fsize = filesize(fstat)
40684068
if fsize != fsize_req
40694069
@debug "Rejecting stale cache file $cachefile because file size of $f has changed (file size $fsize, before $fsize_req)"
4070-
record_reason(reasons, "include_dependency fsize change")
4070+
record_reason(reasons, "file size changed")
40714071
return true
40724072
end
40734073
hash = isdir(fstat) ? _crc32c(join(readdir(f))) : open(_crc32c, f, "r")
40744074
if hash != hash_req
40754075
@debug "Rejecting stale cache file $cachefile because hash of $f has changed (hash $hash, before $hash_req)"
4076-
record_reason(reasons, "include_dependency fhash change")
4076+
record_reason(reasons, "file content changed")
40774077
return true
40784078
end
40794079
end
@@ -4101,7 +4101,7 @@ end
41014101
checksum = isvalid_cache_header(io)
41024102
if iszero(checksum)
41034103
@debug "Rejecting cache file $cachefile due to it containing an incompatible cache header"
4104-
record_reason(reasons, "incompatible header")
4104+
record_reason(reasons, "different Julia build configuration")
41054105
return true # incompatible cache file
41064106
end
41074107
modules, (includes, _, requires), required_modules, srctextpos, prefs, prefs_hash, clone_targets, actual_flags = parse_cache_header(io, cachefile)
@@ -4114,7 +4114,7 @@ end
41144114
requested flags: $(requested_flags) [$(_cacheflag_to_uint8(requested_flags))]
41154115
cache file: $(CacheFlags(actual_flags)) [$actual_flags]
41164116
"""
4117-
record_reason(reasons, "mismatched flags")
4117+
record_reason(reasons, "different compilation options")
41184118
return true
41194119
end
41204120
pkgimage = !isempty(clone_targets)
@@ -4123,7 +4123,7 @@ end
41234123
if JLOptions().use_pkgimages == 0
41244124
# presence of clone_targets means native code cache
41254125
@debug "Rejecting cache file $cachefile for $modkey since it would require usage of pkgimage"
4126-
record_reason(reasons, "requires pkgimages")
4126+
record_reason(reasons, "native code caching disabled")
41274127
return true
41284128
end
41294129
rejection_reasons = check_clone_targets(clone_targets)
@@ -4132,12 +4132,12 @@ end
41324132
Reasons=rejection_reasons,
41334133
var"Image Targets"=parse_image_targets(clone_targets),
41344134
var"Current Targets"=current_image_targets())
4135-
record_reason(reasons, "target mismatch")
4135+
record_reason(reasons, "different system or CPU target")
41364136
return true
41374137
end
41384138
if !isfile(ocachefile)
41394139
@debug "Rejecting cache file $cachefile for $modkey since pkgimage $ocachefile was not found"
4140-
record_reason(reasons, "missing ocachefile")
4140+
record_reason(reasons, "native code cache file not found")
41414141
return true
41424142
end
41434143
else
@@ -4146,15 +4146,15 @@ end
41464146
id = first(modules)
41474147
if id.first != modkey && modkey != PkgId("")
41484148
@debug "Rejecting cache file $cachefile for $modkey since it is for $id instead"
4149-
record_reason(reasons, "for different pkgid")
4149+
record_reason(reasons, "different package identifier")
41504150
return true
41514151
end
41524152
id_build = id.second
41534153
id_build = (UInt128(checksum) << 64) | (id_build % UInt64)
41544154
if build_id != UInt128(0)
41554155
if id_build != build_id
41564156
@debug "Ignoring cache file $cachefile for $modkey ($(UUID(id_build))) since it does not provide desired build_id ($((UUID(build_id))))"
4157-
record_reason(reasons, "for different buildid")
4157+
record_reason(reasons, "different build identifier")
41584158
return true
41594159
end
41604160
end
@@ -4180,20 +4180,20 @@ end
41804180
continue
41814181
elseif M == Core
41824182
@debug "Rejecting cache file $cachefile because it was made with a different julia version"
4183-
record_reason(reasons, "wrong julia version")
4183+
record_reason(reasons, "different Julia version")
41844184
return true # Won't be able to fulfill dependency
41854185
elseif ignore_loaded || !stalecheck
41864186
# Used by Pkg.precompile given that there it's ok to precompile different versions of loaded packages
41874187
else
41884188
@debug "Rejecting cache file $cachefile because module $req_key is already loaded and incompatible."
4189-
record_reason(reasons, "wrong dep version loaded")
4189+
record_reason(reasons, "different dependency version already loaded")
41904190
return true # Won't be able to fulfill dependency
41914191
end
41924192
end
41934193
path = locate_package(req_key) # TODO: add env and/or skip this when stalecheck is false
41944194
if path === nothing
41954195
@debug "Rejecting cache file $cachefile because dependency $req_key not found."
4196-
record_reason(reasons, "dep missing source")
4196+
record_reason(reasons, "dependency source file not found")
41974197
return true # Won't be able to fulfill dependency
41984198
end
41994199
depmods[i] = (path, req_key, req_build_id)
@@ -4212,7 +4212,7 @@ end
42124212
break
42134213
end
42144214
@debug "Rejecting cache file $cachefile because it provides the wrong build_id (got $((UUID(build_id)))) for $req_key (want $(UUID(req_build_id)))"
4215-
record_reason(reasons, "wrong dep buildid")
4215+
record_reason(reasons, "different dependency build identifier")
42164216
return true # cachefile doesn't provide the required version of the dependency
42174217
end
42184218
end
@@ -4228,7 +4228,7 @@ end
42284228
if !(isreadable(stdlib_path) && samefile(stdlib_path, modpath))
42294229
!samefile(fixup_stdlib_path(includes[1].filename), modpath)
42304230
@debug "Rejecting cache file $cachefile because it is for file $(includes[1].filename) not file $modpath"
4231-
record_reason(reasons, "wrong source")
4231+
record_reason(reasons, "different source file path")
42324232
return true # cache file was compiled from a different path
42334233
end
42344234
end
@@ -4237,7 +4237,7 @@ end
42374237
pkg = identify_package(modkey, req_modkey.name)
42384238
if pkg != req_modkey
42394239
@debug "Rejecting cache file $cachefile because uuid mapping for $modkey => $req_modkey has changed, expected $modkey => $(repr("text/plain", pkg))"
4240-
record_reason(reasons, "dep uuid changed")
4240+
record_reason(reasons, "dependency identifier changed")
42414241
return true
42424242
end
42434243
end
@@ -4248,22 +4248,22 @@ end
42484248

42494249
if !isvalid_file_crc(io)
42504250
@debug "Rejecting cache file $cachefile because it has an invalid checksum"
4251-
record_reason(reasons, "invalid checksum")
4251+
record_reason(reasons, "cache file checksum is invalid")
42524252
return true
42534253
end
42544254

42554255
if pkgimage
42564256
if !isvalid_pkgimage_crc(io, ocachefile::String)
42574257
@debug "Rejecting cache file $cachefile because $ocachefile has an invalid checksum"
4258-
record_reason(reasons, "ocachefile invalid checksum")
4258+
record_reason(reasons, "native code cache checksum is invalid")
42594259
return true
42604260
end
42614261
end
42624262

42634263
curr_prefs_hash = get_preferences_hash(id.uuid, prefs)
42644264
if prefs_hash != curr_prefs_hash
42654265
@debug "Rejecting cache file $cachefile because preferences hash does not match 0x$(string(prefs_hash, base=16)) != 0x$(string(curr_prefs_hash, base=16))"
4266-
record_reason(reasons, "preferences hash mismatch")
4266+
record_reason(reasons, "package preferences changed")
42674267
return true
42684268
end
42694269

0 commit comments

Comments
 (0)