-
-
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
Second "using" is slow (slower than third, can even be slower than the first) #36005
Comments
This is because loading eg Plots invalidates some of the code loading code itself. |
Ok, good to know, even better would be to know what that means and how to fix. Is this documented? |
Great question. There's lots of attention to this issue right now, and after a few issues are fixed in Julia itself there will be a blog post: JuliaLang/www.julialang.org#794. |
I'm not sure it's invalidations as Kristoffer states. Why does it happen (I guess your blog explains, if that's the fact), or more importantly why doesn't it happen for 3rd and all subsequent? I took a look at the very long (that's not bad, I want to read it eventually) blog post as you can see from my review, but I admit I did so far only scan it (and neither read most comments to it). I was a bit surprised to see |
Because then the invalidations have resolved.
All julia code in a session share a global method table so being in a different package isn't really relevant. |
It at least feels like a bug, and second should be the fastest, from then on (as nothing was done, in-between). I don't have to understand this fully, but like to, most will not care why or even realize, those extra cumulative seconds. |
Loading code was done and loading code can invalidate old code (as the blog post describes). |
It's not a bug. The first
At one time we did something like that. @vtjnash changed it but I don't remember why. Any reason we can't always use |
Ok that makes more sense, than my understanding of what Kristoffer said. I thought he was referring to the second loading, so I thought why not the third then too. Anyway I was trying new:
You seem to know how to "fix" this "non-bug" (I meant "bug" as in could be improved, not like a serious wrong-results problem), so I leave it to you guys (and gals), as maybe not most important "bug", but something/anything to help slow compile situation a bit. |
I think it got partly reverted in #28290 because it caused problems with loggers (JuliaLang/IJulia.jl#677, JunoLab/Juno.jl#171). |
Same symptom of invalidations, just additionally slower than first using, so even weirder:
|
Ref #36005 (comment) |
So is this actionable? If we're not going to freeze the loading world age, I suppose someone could investigate which call-sites are causing this in the package loading code and potentially fix/avoid instabilities. Otherwise, this seems to be well-covered by the more general reducing-invalidation issues. |
Yes. Best course of action for now is:
While I suspect we might eventually have to consider freezing world-age or other similar steps, so far the majority of invalidations, when prodded, have taught me something about the code that seems better if we just fix the issue. I'd hate to miss out on such a nice opportunity for improving our engineering. With the tools it's pretty quick (a matter of a couple minutes) to figure out what's going on with each invalidation. |
Even on my recent:
Second and all subsequent
using
should all be as fast (not only about Plots.jl). You could ask yourself, why do them, but could well happen in real-world code, and anyway this seems like a low-hanging fruit that should be fixed.Note, this doesn't happen with all packages, so first I thought it would be a problem with those packages, but I'm not sure. At least none of those I've informed knew of this or have any idea why it happens.
I'm not complaining--here--about the first slow
using
(a whole separate issue), nor the the even worse (i.e. first one above is not that):JuliaPlots/Plots.jl#2590
The text was updated successfully, but these errors were encountered: