-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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 at-everywhere import modules before remote calls #21718
Conversation
Wouldn't it be better to treat |
Having |
base/distributed/macros.jl
Outdated
@@ -48,6 +48,24 @@ macro fetchfrom(p, expr) | |||
:(remotecall_fetch($thunk, $(esc(p)))) | |||
end | |||
|
|||
# extract a list of modules to import from an expression | |||
extract_imports(x) = Symbol[] | |||
function extract_imports(ex::Expr) |
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.
Not sure whether it's a big deal, but this might be more efficient as
function extract_imports!(imports, ex::Expr)
and having the everywhere
caller execute it as extract_imports!(Symbol[], ex)
. That way you don't have to allocate an array for every single token.
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.
Good point, will do.
+100 to this PR. -1000 on having |
That was a stupid suggestion. I was under the mistaken assumption that |
I eliminated the unnecessary array allocations mentioned by @timholy, as well as unnecessary allocations introduced by For the latter, since we already supported |
test/meta.jl
Outdated
@@ -122,13 +122,17 @@ using Base.Meta | |||
|
|||
@test isexpr(:(1+1),Set([:call])) | |||
@test isexpr(:(1+1),Vector([:call])) | |||
@test isexpr(:(1+1),(:call)) |
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.
Did you mean to pass a tuple 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.
whoops, right
Travis failure was a network timeout:
|
Actually, I bet this is working around a bug. No combination of local and remote usings should try to load the same thing twice on one machine. |
Yes, there is an open issue for the bug - #19187 . |
This issue has been known and open for quite sometime, hence I am for merging this workaround for now - can be removed when the bug is fixed. |
Hang on, I might have a fix. |
Ok, I've been trying various things. The immediate cause of the issue is that |
this should have been squashed, the intermediate commits fail tests |
… calls (cherry picked from commit 66b8036) ref #21718 don't insert toplevel expression unless there are imports (cherry picked from commit 18291b0) eliminate unnecessary array allocations from isexpr and extract_imports functions (cherry picked from commit 305037a) test fixes (cherry picked from commit 24a74a5)
After upgrading to 0.6 I started having
Is the above error intended or is it a bug? @iblis17 suggested to use |
@pwl, you can't do a |
@stevengj you are totally right, my mistake. In any case, the error is rather cryptic, without the |
This PR is intended to make
@everywhere using Foo
a bit more reliable and performant, by turning it into essentiallyimport Foo; @everywhere using Foo
. Similarly for@everwhere begin ... end
and other blocks that might containimport
orusing
statements.e.g. right now
@everywhere using Foo
givesWARNING: replacing module Foo.
because it ends up importing Foo twice, and that in turn can cause problems with certain modules (e.g. PyCall: JuliaPy/PyCall.jl#388) that don't like to be initialized twice. Also there are potential race conditions with cache recompilation.Not completely sure how to implement a test for this.