-
-
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
Precompile everything after Pkg.update() and friends #16409
Comments
Different people have different workstyles, so putting this precompilation step as default in Pkg.update doesn't sound right to me... |
|
This would also be helpful for MPI programs on clusters with a shared file system. It would be better to have a single process precompile everything before launching the MPI tasks. Currently, every MPI task precompiles every package. |
I guess another option would be to just have a function |
https://github.com/staticfloat/MakePkgUpdatePrecompileInTheBackground.jl - evidently some of the repl backgrounding cleverness there requires a patch that hasn't been backported to 0.4 (yet? haven't reviewed the branch in detail). |
A separate |
There will probably be people like me who prefer to have something like Another idea (but probably more long term) might be background precompile, like the example @tkelman linked to. .Net has something like that as well with background ngen compilation. Not sure how successful that is... |
$ echo 'Pkg.precompile_stale()' > ~/.juliarc.jl if such a function gets added? |
Hm, that would still be unpredictable, now I could never be sure whether I will wait for precompile at julia startup. I would really prefer that it just happens automatically after any operation via the package manager. |
@davidanthoff, in the meantime you can always add this to your function recompile()
for pkg in Pkg.available()
try
pkgsym = Symbol(pkg)
eval(:(using $pkgsym))
catch
end
end
end
pkgupdate() = (Pkg.update(); recompile()) Not perfect, but pretty useful. |
@timholy Any reason I shouldn't use |
|
What's the problem with precompiling packages on install by default? According to the "vote" at the top, this makes a lot of sense. The issue with leaving it opt-in is that only advanced users will find out about this, which will give the impression that Julia is slow any time they will show it to their colleagues after an update. |
In the long run precompilation should be hidden somewhere in a background job. Currently precompilation takes time and blocks REPL - several minutes. As a user and developer i'd like to take control when this happens. Also currently Pkg.update (depending on the connectivity?) gets slower and slower and spending additional time on recompilation ... i just don't know. |
If precompile happend with package operations, I wonder whether one could do some clever async weaving. If |
Another idea is to enable automatic precompile after package operations for one release (with an option to disable it via |
Precompilation can only be done when package and its dependencies are updated and built. I believe, there is no particular order in update operation, so some reordering is needed for to enable precompilation while downloading rest of the updates. |
So, hypothetically, there's a new Julia user, and some tells them about a new package they should try. So they type Pkg.update()
Pkg.add("UnicodePlots")
using UnicodePlots and would expect that to be as fast as possible. Having to wait for My problems and workflows shouldn't enter the discussion here, since I already know how to circumvent problems and configure things. But having to explain to a new user that |
You do not need to run |
Julia often tells me to run Anyway -- if we first improve I realize this is a discussion only about the default behaviour; all the features that people need will be there anyway. So my point is that the default should be right for beginners -- it should not surprise beginners. Letting experienced users save a few keystrokes isn't the right choice for interactive package management. |
I think the current behavior of
It already is, even without precompile. And it will always be unpredictable, given that packages can do whatever they like in their
I think this is a bad user experience. Users now have to remember whether they have used that package before in order to tell whether the command will be slow or not, which is really unpredictable. |
I'm not arguing that Compare to I want separate |
Yes, a fast metadata update would be great. But that is not |
@davidanthoff It seems we are in agreement now. |
@eschnett Looks like you're asking for an equivalent of |
I guess here is another way to split this: there could be one operation that git fetches everything (both METADATA and all local package repos), but does NOT change the checked out version of any package on the system. Even for checked out packages this would just fetch, not pull. The only folder that would be git pulled would be METADATA. So you can actually be sure that not a single of your installed packages will be changed by that command. [at this moment of writing @nalimilan's comment appeared] And then have another command that upgrades all packages to their latest available version, like @nalimilan's This would enable a whole bunch of nice things: one could do a In that model, whenever the checked out version in a package directory is changed by the package manager, it would be precompiled. |
@davidanthoff "... it would be precompiled." You probably mean "it and all its dependents" here. |
@eschnett: Yes. But unless the change of version of package X also changed the checked out versions of the packages it depends on, those packages would already be precompiled and would not have to be recompiled, I believe. |
@davidanthoff I meant dependents as in children, not dependencies as in parents. As in, you update package X, and then you need to check all other packages whether they depend on X, and recompile them as well. |
Yes. Currently, each time Compat.jl is updated nearly all the packages, that I use need to be recompiled, because they all depend on Compat.jl. |
@eschnett Ah, yes, that is right. |
I use a slightly different version of Tim's function, but it also does function recompile_packages()
for pkg in keys(Pkg.installed())
try
info("Compiling: $pkg")
eval(Expr(:toplevel, Expr(:using, Symbol(pkg))))
println(SEPARATOR)
catch err
warn("Unable to precompile: $pkg")
warn(err)
println(SEPARATOR)
end
end
end
emerge() = (Pkg.update(); Pkg.build(); recompile_packages()) |
Hi, sorry for the bump, but I think this warrants further discussion. I would consider myself a beginner, and my use-case (and I think a lot of people in the sciences like myself) want to do something like use Julia in a REPL or Jupyter Notebook to do some nice data exploration type tasks (like how people use Matlab). Opening up Jupyter and then running I think that having |
Once finals are over, I'd gladly take this on myself if no one else wants to. Been meaning to learn more of Julia's internals! |
I wrote myself a batch script that
|
My version here, pretty ugly. It stops when a compilation task failed.
|
I suggest to add the emerge function mentioned above under the name Pkg.upgrade() to Julia 0.7. Very little work, very useful. Just needs documentation. So, please add the label "1.0". |
Package management and precompilation is going to be quite different in 0.7, so this thread while well-intentioned and useful under the premise that Pkg is going to stay much the same, that premise isn't true and this is not actually very helpful. Something in the spirit of this thread can and will certainly be supported, however. Changing how and when compilation happens is not a breaking change, so even if we wanted to do this, the issue would not be a 1.0-blocker and therefore does not belong on the milestone. |
To be clear, we are going to have precompilation in 1.0, right? As ufechner7 said, this is a small change that would give a large user experience improvement. Papercuts like this really add up and can make or break adoption. If 1.0 does not have a smooth like butter user experience, it shouldn't be called 1.0. |
@holocronweaver, to be clear, Julia has precompilation now — the issue here is when this happens (a (The Julia developers have decided that 1.0 is about backwards compatibility, not "smooth like butter user experience." Certainly when 1.0 is released it should be clear that many improvements are still in the queue.) |
I meant precompilation during installing/upgrading. Precompiling libraries when you run scripts should only be done as last resort or during library development. As you say, scripts above can accomplish this, but it is absurd to ask users to write such scripts when the package manager should have it built in and it is trivial to implement. (Releasing an unpolished product as 1.0 will surely drop Julia adoption rate and feed into the "Julia will never gain wide adoption" narrative that is common among scientists and engineers.) |
I'm not exactly sure how many times I can possibly assure people that I'm aware of this being a desire and that we'll ship with something to address this but also say that this particular implementation does not make any sense in Pkg3. |
Sorry, I think there is a misunderstanding. My question was: will some implementation be included in 1.0? My concern: I think this is too important to user experience not to be a 1.0-blocker. |
Sure |
@StefanKarpinski could you please explain that "we'll ship with something" in more detail? |
@lobingera, probably easiest if you checkout Pkg3. |
@mauro3, i'm in the process of switching my package repo to Pkg3 right now. Stefan's comment sounded to me like, there is "something" on top to be expected ... |
@lobingera, please be patient. I can either spend time working on it or explaining it, not both. Also the exact nature of the feature remains to be determined and will probably evolve after the feature freeze since changing how precompilation works is a non-breaking change. |
There is now a |
This issue is meant as a discussion starter, I'm actually not sure it should actually be done ;)
Here is my situation: I normally
Pkg.update()
in the morning. I know it will take some time, so I typically do it when I don't need a julia prompt the next second. Later that day someone comes by the office, and I want to show him/her how cool and fast julia is. I start my neat example code, and it all starts by spending a couple of minutes precompiling things. And I stutter "uh, oh, precompile, you know...". It bites me every time I try to demo julia.At least for me I would much prefer if precompile happend with
Pkg.update()
. I'm already in a mood that things will take a while when I runPkg.update()
, so if they take a little longer, no problem. Whereas precompile on demand seems to hit me always in moments when it is really, really inconvenient. Having precompile as part ofPkg.update()
would make things much more predictable, which is something I would value.For this example, precompile should probably also be triggered by all the other
Pkg.*
functions that change packages.Alternatives:
Pkg.update(precompile=true)
. Would work but I would probably forget it, and then the precompile cost would again hit me in an inconvenient moment.Thoughts?
The text was updated successfully, but these errors were encountered: