Pkg.jl: opt-in precompilation after Pkg.update when laptop is on battery

Created on 13 Oct 2020  路  8Comments  路  Source: JuliaLang/Pkg.jl

It's not very nice if your laptop is on battery and you happen to do a up, which I regularly do a lot. To keep the battery last longer, some of the precompilation can be done lazily until you actually need that.

Probably there should be a nice way to make this opt-in when the laptop is on battery.

Most helpful comment

Through the wonders of JLLs, this is now fully cross-platform https://github.com/ianshmean/PowerMonitor.jl

All 8 comments

A single Ctrl-C will gracefully exit auto precompilation after a short wait (I've just added a message to reassure that it is exiting in #2113)

Otherwise, I'm not sure julia can know if the system is running on battery?

Otherwise, I'm not sure julia can know if the system is running on battery?

All the OSes have APIs for this

Seems like a pretty strange thing to do IMO.

@johnnychen94 you might want to just set ENV["JULIA_PKG_PRECOMPILE_AUTO"]=0 and just call pkg> precompile when you want it

It's also worth saying that while 1.6 isn't released, for people working on master a lot of stuff is going to get precompiled again and again as the master commit changes.. Once 1.6 is released, it will be a lot more stable

Precompilation does not always happen in an interactive mode, for example, it can be background cronjob that updates packages in the root project. But I guess I'll live with Ctrl-C.

Yeah, I'm aware of the JULIA_PKG_PRECOMPILE_AUTO mode, and I have regularly switched between two modes because I both like the new precompilation feature and want to make my laptop working a bit longer when it's on battery. I don't have an expectation of what should be the best option here. Probably this is not a Julia Pkg thing and probably the best option is just to set a watchdog daemon to automate the switches.

@johnnychen94 I knocked together https://github.com/ianshmean/PowerMonitor.jl which provides the following that can be added to .julia/config/startup.jl to disable auto-precomp when on battery.

import PowerMonitor
PowerMonitor.autoprecomp_notbattery()

I've only tested it on MacOS, but linux _should_ be supported.
I'm sure the code and function names could be nicer. PR's welcome!

This looks really nice and clean! Sounds like a better place than Pkg to give it an implementation so I'll close it here.

Thanks again for all the parallel precompilation work!

Through the wonders of JLLs, this is now fully cross-platform https://github.com/ianshmean/PowerMonitor.jl

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KristofferC picture KristofferC  路  4Comments

jlperla picture jlperla  路  3Comments

jaabadi picture jaabadi  路  3Comments

GregPlowman picture GregPlowman  路  3Comments

omus picture omus  路  4Comments