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

Add --compiled-modules=existing command line option #50586

Merged
merged 2 commits into from
Jul 19, 2023
Merged

Conversation

Keno
Copy link
Member

@Keno Keno commented Jul 18, 2023

Occasionally when developing new compiler features, it is not possible for me to precompile the package I'm developing (because it relies on the new compiler features, which are only available if Revise'd in). --compiled-modules=no is an option, but for packages with deep dependency stacks, this is not practical (in addition to slowing down use of development utilities like Revise, Cthulhu or Plots). Originally I tried to add a mode to --compiled-modules that would avoid using compiled modules for anything that's dev'ed, but that's a pretty complicated thing to figure out in the loading code, because you could have a non-dev'ed package that depends on a dev'ed package and you'd want to avoid loading that as well, but we don't technically have explicit dependency links at the loading level. This sidesteps all that and just adds a simpler option: nonew existing. This option simply uses any pre-existing cache files if they exist, but refuses to create new ones. This does effectively the same thing, because the only packages with stale cache files are usually the ones that I've edited. However, the semantics are much simpler for loading to implement.

Occasionally when developing new compiler features, it is not possible
for me to precompile the package I'm developing (because it relies on
the new compiler features, which are only available if Revise'd in).
`--compiled-modules=no` is an option, but for packages with deep
dependency stacks, this is not practical (in addition to slowing down
use of development utilities like Revise, Cthulhu or Plots).
Originally I tried to add a mode to `--compiled-modules` that would
avoid using compiled modules for anything that's dev'ed, but that's
a pretty complicated thing to figure out in the loading code,
because you could have a non-`dev`'ed package that depends on a
`dev`'ed package and you'd want to avoid loading that as well, but
we don't technically have explicit dependency links at the loading
level. This sidesteps all that and just adds a simpler option: `nonew`.
This option simply uses any pre-existing cache files if they exist,
but refuses to create new ones. This does effectively the same thing,
because the only packages with stale cache files are usually the ones
that I've edited. However, the semantics are much simpler for loading
to implement.
@Keno Keno requested a review from KristofferC July 18, 2023 15:17
@@ -101,7 +101,7 @@ The following is a complete list of command-line switches available when launchi
|`--startup-file={yes*\|no}` |Load `JULIA_DEPOT_PATH/config/startup.jl`; if `JULIA_DEPOT_PATH` environment variable is unset, load `~/.julia/config/startup.jl`|
|`--handle-signals={yes*\|no}` |Enable or disable Julia's default signal handlers|
|`--sysimage-native-code={yes*\|no}` |Use native code from system image if available|
|`--compiled-modules={yes*\|no}` |Enable or disable incremental precompilation of modules|
|`--compiled-modules={yes*\|no|nonew}` |Enable or disable incremental precompilation of modules|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs some extra docs. How about

nonew uses any precompiled modules that already exist, but will not compile new modules.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reasonable to put in the docs, but I'd keep it out of the cli usage note, since it's a bit of a niche flag.

@maleadt
Copy link
Member

maleadt commented Jul 19, 2023

This will also be useful for CReduce+Julia!

This option simply uses any pre-existing cache files if they exist, but refuses to create new ones.

Maybe --compiled-modules=existing is a bit clearer then?

@Keno
Copy link
Member Author

Keno commented Jul 19, 2023

Maybe --compiled-modules=existing is a bit clearer then?

Sure

@Keno Keno merged commit bd8734f into master Jul 19, 2023
@Keno Keno deleted the kf/compilednonew branch July 19, 2023 17:40
@oscardssmith oscardssmith changed the title Add --compiled-modules=nonew command line option Add --compiled-modules=existing command line option Jul 19, 2023
KristofferC pushed a commit that referenced this pull request Dec 19, 2023
Equivalent of #50586; implements
#51474.

With `--pkgimages=existing`, it's possible to disable the (often slow)
generation of package images, without losing the ability to use existing
ones. That's important now that we're moving more and more packages
outside of the system image, e.g., running with `--pkgimages=no`
otherwise takes close to 30s here before the Pkg REPL is usable.

The main motivation for this is PkgEval, where generating package images
is not very useful, yet disabling generation of them makes each job
(which requires Pkg to drive the test process) take a significantly
longer time.

For example, `--pkgimages=yes` vs `no`:

```julia
❯ JULIA_DEBUG=loading ./julia --project=Example.jl --pkgimages=yes
# no precompilation of REPL.jl
┌ Debug: Loading object cache file /Users/tim/Julia/src/julia/build/dev/usr/share/julia/compiled/v1.11/REPL/u0gqU_XmENM.dylib for REPL [3fa0cd96-eef1-5676-8a61-b3b8758bbffb]
└ @ Base loading.jl:1116

julia> using Example
# short time precompiling + pkgimg generation for Example.jl
┌ Debug: Loading object cache file /Users/tim/.julia/compiled/v1.11/Example/lLvWP_tJaso.dylib for Example [7876af07-990d-54b4-ab0e-23690620f79a]
└ @ Base loading.jl:1116
```

```julia
❯ JULIA_DEBUG=loading ./julia --project=Example.jl --pkgimages=no
┌ Debug: Rejecting cache file /Users/tim/Julia/src/julia/build/dev/usr/share/julia/compiled/v1.11/REPL/u0gqU_XmENM.ji for REPL [3fa0cd96-eef1-5676-8a61-b3b8758bbffb] since the flags are mismatched
│   current session: use_pkgimages = false, debug_level = 1, check_bounds = 0, inline = true, opt_level = 2
│   cache file:      use_pkgimages = true, debug_level = 1, check_bounds = 0, inline = true, opt_level = 2
└ @ Base loading.jl:3289
# long time precompiling REPL.jl
┌ Debug: Loading cache file /Users/tim/.julia/compiled/v1.11/REPL/u0gqU_CWvWI.ji for REPL [3fa0cd96-eef1-5676-8a61-b3b8758bbffb]
└ @ Base loading.jl:1119

julia> using Example
# short time precompiling Example
┌ Debug: Loading cache file /Users/tim/.julia/compiled/v1.11/Example/lLvWP_CWvWI.ji for Example [7876af07-990d-54b4-ab0e-23690620f79a]
└ @ Base loading.jl:1119
```

With the new `--pkgimages=existing`:

```julia
❯ JULIA_DEBUG=loading ./julia --project=Example.jl --pkgimages=existing
# no precompilation of REPL.jl
┌ Debug: Loading object cache file /Users/tim/Julia/src/julia/build/dev/usr/share/julia/compiled/v1.11/REPL/u0gqU_XmENM.dylib for REPL [3fa0cd96-eef1-5676-8a61-b3b8758bbffb]
└ @ Base loading.jl:1116

julia> using Example
# short time precompiling Example
┌ Debug: Loading cache file /Users/tim/.julia/compiled/v1.11/Example/lLvWP_CWvWI.ji for Example [7876af07-990d-54b4-ab0e-23690620f79a]
└ @ Base loading.jl:1119
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants