-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
check if cachefile dependencies can be fulfilled #21492
Conversation
base/loading.jl
Outdated
|
||
# Check if transitive dependencies can be fullfilled | ||
for mod in keys(required_modules) | ||
isdefined(Main, mod) && continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to check here for :Core, :Base, ...
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why would staleness depend on the in memory state of Main?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am checking if the module is already loaded here, since if it is read_verify_mod_list
from dump.c
, won't fail. Just added a commit to be more explicit (it safes a few calls to find_in_node_path
)
A different solution that would probably work, but is imho tricky to implement: Ensure a consistent ordering in the module dependency list, so that direct dependencies are loaded first. But at the point where that list is written we have no information about direct or indirect dependencies. |
for testing, we should be able to create a stack of 3 placeholder modules. Precompile the top one, then remove the bottom one and change the middle to not depend on it any more. That should reproduce the failure on master I believe. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hate to slow it down this much (I've seen find_in_node_path
can be a hot spot), since it'll probably cause a measurable performance regression in #15048). But this looks valid.
base/loading.jl
Outdated
@@ -699,7 +699,16 @@ function parse_cache_header(f::IO) | |||
push!(files, (String(read(f, n)), ntoh(read(f, Float64)))) | |||
end | |||
@assert totbytes == 4 "header of cache file appears to be corrupt" | |||
return modules, files | |||
# read the list of modules that are required to be present during loading | |||
required_modules = Dict{Symbol, UInt64}() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick :P but no space between {Symbol,UInt64}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a test. (Developed against master with |
test/compile.jl
Outdated
""") | ||
rm(FooBarT_file) | ||
@test Base.stale_cachefile(FooBarT2_file, joinpath(dir2, "FooBarT2.ji")) | ||
# Before #21492 this would fail: Base.require(:FooBarT2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't we run it then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My logic was that if the line above fails it should also fail (and we don't quite have a @test_nothrow
), but you are right it shouldn't hurt also doing it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could test that it returns === nothing
if that's what it's supposed to do
I addressed all comments, there was one intermediate travis failure that is backed here https://gist.github.com/vchuravy/aa4a715b99ef33435892bfd934bcc577, but it seems unrelated. |
with regard to performance (all tests done on a clean PKGDIR and after This branch
Current master
@vtjnash is there a better way to check the performance impact? Right now it seems imperceptible, but it might be worse if the |
Those timings look good. |
this PR breaks Gadfly.jl's ability to pre-compile:
|
Thanks for letting me know I am looking into it. What version of Compose/Gadfly are you using? |
i'm on the master branch of each. |
I have also gotten the |
i've checkout out e0c497b and everything works fine. |
I got the same error just now, and as for julia> using AxisArrays
INFO: Recompiling stale cache file /home/fredrik/.julia/lib/v0.6/AxisArrays.ji for module AxisArrays.
WARNING: The call to compilecache failed to create a usable precompiled cache file for module AxisArrays. Got:
WARNING: Module Iterators uuid did not match cache file.
ERROR: LoadError: Declaring __precompile__(true) is only allowed in module files being imported.
Stacktrace:
[1] __precompile__(::Bool) at ./loading.jl:318
[2] __precompile__() at ./loading.jl:314
[3] include_from_node1(::String) at ./loading.jl:539
[4] eval(::Module, ::Any) at ./boot.jl:235
[5] require(::Symbol) at ./loading.jl:453
while loading /home/fredrik/.julia/v0.6/AxisArrays/src/AxisArrays.jl, in expression starting on line 1 |
@vtjnash I might need your help here In a fresh Julia session
But when we are restoring the module in |
x-ref #19108, possibly relevant? |
This works around `Base.Iterators` shadowing `Iterators`, as noted in #21492.
if mod == :Main || mod == :Core || mod == :Base | ||
continue | ||
# Module is already loaded | ||
elseif isdefined(Main, mod) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs a check for isbindingresolved(Main, mod)
first, to avoid causing isdefined
to resolve the binding
Fix wrong use of `isdefined` #21492
(cherry picked from commit 36bb61a)
Fixes #21266. I was not able to reproduce the original issue,
because the dependency chain changed and
DataArrays
alsodepends on
SpecialFunctions
.We are writing transitive dependencies to the
.ji
file,because at the moment of loading the
.ji
files there is nodifference between transitive dependencies or direct dependencies.
Just a list of preconditions, that need to be fullfilled.
Instead of changing that fairly complex piece of logic during
feature freeze I decided to try a less disruptive approach
and check in
stale_cachefile
, if all dependencies areavailable.
Any suggestions for tests?