Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make cache mismatch log more informative #48168

Merged
merged 2 commits into from
Jan 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2505,6 +2505,30 @@ function check_clone_targets(clone_targets)
end
end

struct CacheFlags
# ??OOCDDP - see jl_cache_flags
use_pkgimages::Bool
debug_level::Int
check_bounds::Bool
opt_level::Int

CacheFlags(f::Int) = CacheFlags(UInt8(f))
function CacheFlags(f::UInt8)
s = bitstring(f)
IanButterworth marked this conversation as resolved.
Show resolved Hide resolved
use_pkgimages = parse(Bool, s[end])
debug_level = parse(Int, s[end-2:end-1], base=2)
check_bounds = parse(Bool, s[end-3])
opt_level = parse(Int, s[end-5:end-4], base=2)
new(use_pkgimages, debug_level, check_bounds, opt_level)
end
end
function show(io::IO, cf::CacheFlags)
print(io, "use_pkgimages = ", cf.use_pkgimages)
print(io, ", debug_level = ", cf.debug_level)
print(io, ", check_bounds = ", cf.check_bounds)
print(io, ", opt_level = ", cf.opt_level)
end

# returns true if it "cachefile.ji" is stale relative to "modpath.jl" and build_id for modkey
# otherwise returns the list of dependencies to also check
@constprop :none function stale_cachefile(modpath::String, cachefile::String; ignore_loaded::Bool = false)
Expand All @@ -2523,7 +2547,11 @@ end
return true # ignore empty file
end
if ccall(:jl_match_cache_flags, UInt8, (UInt8,), flags) == 0
@debug "Rejecting cache file $cachefile for $modkey since the flags are mismatched" cachefile_flags=flags current_flags=ccall(:jl_cache_flags, UInt8, ())
@debug """
Rejecting cache file $cachefile for $modkey since the flags are mismatched
current session: $(CacheFlags(ccall(:jl_cache_flags, UInt8, ())))
cache file: $(CacheFlags(flags))
"""
return true
end
pkgimage = !isempty(clone_targets)
Expand Down
1 change: 1 addition & 0 deletions src/staticdata_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ JL_DLLEXPORT uint8_t jl_cache_flags(void)
flags |= (jl_options.opt_level & 3) << 4;
// NOTES:
// In contrast to check-bounds, inline has no "observable effect"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw @vchuravy, what does this mean?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uhm... That I have not used --inline ever.

We should probably still split the cache since if you accidentially compile a pkgimg with --inline it will poison the cache due to

`--compiled-modules`, `--inline`, `--check-bounds`, `--optimize`, `-g`,
&
io = open(pipeline(addenv(`$(julia_cmd(;cpu_target)::Cmd) $(opts)

My original reasoning was that whether we inline or not is not an observable effect, since it is a pure optimization.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will poison the cache due to

Yeah, I was thinking if you run with --inline=no you poison it with very slow code.

// CacheFlags in loading.jl should be kept in-sync with this
return flags;
}

Expand Down