Skip to content

Conversation

vchuravy
Copy link
Member

Delay the loading until we start the REPL.

out of discussion with @ViralBShah

Delay the loading until we start the REPL.

Co-authored-by: Viral B. Shah <[email protected]>
@ViralBShah
Copy link
Member

ViralBShah commented Oct 15, 2025

Thanks @vchuravy. The thing that it seems will prevent this from merging will be increased latency. It would at least be good to measure it.

Helps upgradeable stdlibs: #59855

Co-authored-by: Jameson Nash <[email protected]>
@ViralBShah
Copy link
Member

ViralBShah commented Oct 16, 2025

I'm not sure if I did something wrong, but I made a clean build from this PR, and this is what I observe. The Julia startup is a bit faster. Loading LinearAlgebra is a bit slower but it is still sub second. The first factorization is a bit slower, but slowdown is small enough that I would much rather have the flexibility.

   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.13.0-DEV.1319 (2025-10-16)
 _/ |\__'_|_|_|\__'_|  |  vs+vc/delayed_loaded_linearalgebra/b4c24481b1 (fork: 2 commits, 1 day)
|__/                   |

julia> @time using LinearAlgebra
  0.003710 seconds (6.09 k allocations: 1.170 MiB)

julia> @time lu(rand(10,10));
  0.113652 seconds (383.98 k allocations: 18.426 MiB, 7.83% gc time, 93.92% compilation time)
 julia  
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.12.0 (2025-10-07)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org release
|__/                   |

julia> @time using LinearAlgebra
  0.000434 seconds (302 allocations: 23.953 KiB)

julia> @time lu(rand(10,10));
  0.000284 seconds (6 allocations: 1.984 KiB)

It also feels like the startup time is much lesser. The first one is this PR and the second one is stock julia 1.12.

➜  julia git:(vs+vc/delayed_loaded_linearalgebra) time ./julia -e "exit()"
./julia -e "exit()"  0.07s user 0.04s system 94% cpu 0.112 total
➜  julia git:(vs+vc/delayed_loaded_linearalgebra) time julia -e "exit()"  
julia -e "exit()"  0.12s user 0.04s system 98% cpu 0.162 total

The system image is 198M with LinearAlgebra (on 1.12) and 145M without (on this PR).

@ViralBShah
Copy link
Member

cc @dkarrasch @jishnub

return nothing
end
end
Core._using(mod, MainInclude.LinearAlgebra)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should do this; LinearAlgebra is not using'd by default currently. We also don't need the identifier in MainInclude as far as I can tell.

@KristofferC
Copy link
Member

I don't understand what the REPL has to do with anything and why you would want to load LinearAlgebra automatically in it. How does this get around the reasons we haven't moved it out already?

@ViralBShah
Copy link
Member

I believe the thought here is that it can be outside the system image which means you don't get * etc. when using without the REPL, but you get all the other behaviour when in the REPL.

@KristofferC KristofferC added breaking This change will break code needs pkgeval Tests for all registered packages should be run with this change labels Oct 17, 2025
@JeffBezanson
Copy link
Member

Making it REPL-specific will break scripts. Note we were ok with making InteractiveUtils REPL-specific because it's a bit unusual for a script to use something like @code_typed, but of course it still annoyed some people.

Also in a way this makes LinearAlgebra harder to avoid. Previously if you built a system image without LA, then it wouldn't get loaded, but with this it will be loaded anyway. We could add a sysimage-build-time option (via --buildsettings) to provide a list of packages to load on startup?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking This change will break code needs pkgeval Tests for all registered packages should be run with this change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants