Skip to content
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 JULIA_PRECOMPILE=0 doesn't skip precompilation of stdlibs anymore #55181

Closed
giordano opened this issue Jul 20, 2024 · 10 comments
Closed

make JULIA_PRECOMPILE=0 doesn't skip precompilation of stdlibs anymore #55181

giordano opened this issue Jul 20, 2024 · 10 comments
Labels
domain:building Build system, or building Julia or its dependencies kind:bug Indicates an unexpected problem or unintended behavior

Comments

@giordano
Copy link
Contributor

giordano commented Jul 20, 2024

Already in v1.11.0-alpha1, make JULIA_PRECOMPILE=0 doesn't work anymore to skip precompilation of stdlibs. I'm confused because it looks to me the check in

if Base.isempty(Base.ARGS) || Base.ARGS[1] !== "0"
is still correct (and hasn't been touched in a few years), but maybe the argument isn't passed around correctly. But also
--startup-file=no --warn-overwrite=yes --sysimage $$(call cygpath_w,$$<) $$(call cygpath_w,$$(JULIAHOME)/contrib/generate_precompile.jl) $(JULIA_PRECOMPILE); then \
looks good to me at a quick glance.

Confirmed by @Octogonapus on current master.

@giordano giordano added kind:bug Indicates an unexpected problem or unintended behavior domain:building Build system, or building Julia or its dependencies labels Jul 20, 2024
@giordano
Copy link
Contributor Author

I suspect this was broken by #53403, or something related to base/precompilation.jl, because as far as I understand precompilation happens in that file now, because as far as I can tell printing during precompilation comes from that file. CC: @KristofferC @IanButterworth.

@KristofferC
Copy link
Sponsor Member

Dup of #51145? I don't think this ever "worked".

@giordano
Copy link
Contributor Author

giordano commented Jul 20, 2024

I don't think this ever "worked".

On 532125d (just to pick up an old commit where I'm sure I used to use JULIA_PRECOMPILE=0 effectively):

$ make cleanall; time make -j60
[...]
Sysimage built. Summary:
Base ────────  18.201171 seconds 41.8207%
Stdlibs ─────  25.319237 seconds 58.1758%
Total ───────  43.521916 seconds
    JULIA usr/lib/julia/sys-o.a
Generating REPL precompile statements... 40/40
Executing precompile statements... 1835/1878
Precompilation complete. Summary:
Generation ──  77.660580 seconds 76.7357%
Execution ───  23.544638 seconds 23.2643%
Total ─────── 101.205217 seconds
Outputting sysimage file...
Output ────── 119.377511 seconds
    LINK usr/lib/julia/sys.so

real    6m16.258s
user    8m45.557s
sys     0m6.304s
$ make cleanall; time make -j60 JULIA_PRECOMPILE=0
Sysimage built. Summary:
Base ────────  18.283613 seconds 41.7191%
Stdlibs ─────  25.540378 seconds 58.2774%
Total ───────  43.825553 seconds
    JULIA usr/lib/julia/sys-o.a
Outputting sysimage file...
Output ──────  63.089566 seconds
    LINK usr/lib/julia/sys.so

real    3m38.520s
user    6m8.566s
sys     0m5.207s

These were run after having done a full build to make sure all binaries dependencies are downloaded. Note that when using JULIA_PRECOMPILE=0 the generating/executing precompile statements stages aren't run at all, saving over 40% of total build time. The difference of real time (~158 seconds) is entirely due to not running the precompilation stage (101 seconds vs 0 seconds) and a smaller sysimage to output (119 seconds vs 63 seconds): 101 + 119 - 63 = 157. I'd say in the past JULIA_PRECOMPILE=0 did have an effect. You can also see that when not having precompile statements, Pkg operations were very slow the first time, entirely due to compilation, but that's the whole point of using JULIA_PRECOMPILE=0:

julia> @time Pkg.status()
Status `/data/cceamgi/julia-depot/environments/v1.9/Project.toml` (empty project)
  5.753605 seconds (3.99 M allocations: 305.428 MiB, 1.62% gc time, 95.83% compilation time)

julia> @time Pkg.status()
Status `/data/cceamgi/julia-depot/environments/v1.9/Project.toml` (empty project)
  0.001367 seconds (2.99 k allocations: 190.008 KiB)

As far as I understand, the fact is that base/precompilation.jl doesn't know about JULIA_PRECOMPILE, contrary to contrib/generate_precompile.jl (which seems to still "work").

Dup of #51145?

That issue predates the introduction of base/precompilation.jl.

@IanButterworth
Copy link
Sponsor Member

I think the meaning has changed and it's not clear what it should do. Perhaps we can agree and fix it.

Two meanings I can think of:

  1. Disable precompiling the stdlib pkgimages during make, so package precompilation will be hit when any excised stdlib is loaded
  2. Disable the precompile workloads within the stdlibs, so still precompile them but do less work. Stdlibs will load without needing package precompilation, but they will always have bad TTFX

I believe an issue with 1) is that it can cause stdlib caches to get put into the default depot, which can mess up where caches are looked for until those are deleted.

Maybe we need two settings?

@IanButterworth
Copy link
Sponsor Member

Historically it's been more like 2) because stdlibs used to be in the sysimage, but I think you want 1)?

@KristofferC
Copy link
Sponsor Member

KristofferC commented Jul 20, 2024

I'd say in the past JULIA_PRECOMPILE=0 did have an effect.

I'm talking about precompilation for stdlibs that are not in the sysimage. Earlier when all stdlibs were in the sysimage all precompilation was done from generate_precompile but the stdlibs are precompiled from a separate make stage now.

@vchuravy
Copy link
Member

I have been tempted to pull in PrecompileTools for stdlibs, which would provide a preference based method to opt stdlibs out of their precompiled workloads.

I think Jameson was against using environment variably since that is not tracked by the caching mechanism and so you could get stale cache results into your session by accident.

@giordano
Copy link
Contributor Author

@IanButterworth my goal was to have a "minimal" julia build that can be quickly compiled for git bisection, for those cases where you don't need to pull in (m)any stdlibs for a minimal reproducer. LLVM_PRECOMPILE=0 used to serve that purpose, as I've shown above it could cut build time by over 40%. I think this is indeed the option 1 you suggested, but probably also option 2 would work for the purpose of cutting build time.

If anything, thanks to improved parallelism, on this machine building a recent commit on master (3290904) with all precompilations takes 5:43 (vs 6:16 on 532125d) and precompiling the stdlibs takes 41 seconds (vs 101 on 532125d + larger sysimage), so cutting down precompilation now would save ~10% of build time. Not as much as before in terms of relative saving, but still non-negligible.

@KristofferC
Copy link
Sponsor Member

I still don't understand why this is not a dup of #51145.

@IanButterworth
Copy link
Sponsor Member

At least to me it was unclear whether we were talking about workloads or precompilation entirely. Seems like it's the latter so it is a dup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:building Build system, or building Julia or its dependencies kind:bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

4 participants