-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Regression in package loading on Windows starting in Julia 1.10.0-rc2 #52711
Comments
Here are the commits that were put into rc2: #52045. If someone feels up for it, doing a bisect to find the offending one would be very helpful. |
Offending PR seems to be #51371. Note: #51698 is cherry-picked to fix compilation on Cygwin mingw64. Last good
First bad
|
If I look at what gets compiled when loading precompile(Tuple{typeof(Artifacts._artifact_str), Module, String, Base.SubString{String}, String, Base.Dict{String, Any}, Base.SHA1, Base.BinaryPlatforms.Platform, Any})
precompile(Tuple{typeof(Base.setindex!), Base.EnvDict, String, String})
precompile(Tuple{typeof(Base.getindex), Base.EnvDict, String})
precompile(Tuple{typeof(FFTW.__init__)})
precompile(Tuple{typeof(LazyModules.__init__)}) I think the
seems to confirm that. |
SnoopCompile also shows
which seems to correspond to the bisected PR. The Line 86 in f9b27b3
Maybe this could be changed to a |
The
|
…dows env variables (#52758) Should fix #52711. My analysis of the invalidation is as follows: We added code to cache the conversion to `cwstring` in env handling on Windows (#51371): ```julia const env_dict = IdDict{String, Vector{UInt16}}() function memoized_env_lookup(str::AbstractString) ... env_dict[str] = cwstring(str) ... end function access_env(onError::Function, str::AbstractString) var = memoized_env_lookup(str) ... end ``` Since `IdDict` has `@nospecialize` on `setindex!` we compile this method: ```julia setindex!(::IdDict{String, Vector{UInt16}}, ::Any, ::Any) ``` which has an edge to: ```julia convert(Type{Vector{Int64}}, Any}) ``` But then StaticArrays comes along and adds a method ```julia convert(::Type{Array{T, N}}, ::StaticArray) ``` which invalidates the `setindex!` (due to the edge to `convert`) which invalidates the whole env handling on Windows which causes 4k other methods downstream to be invalidated, in particular, the artifact string macro which causes a significant delay in the next jll package you load after loading StaticArrays. There should be no performance penalty to this since strings already does a hash for their `objectid`.
This was in an attempt to fix #52711 which ultimately proved unsuccessful. This might however still be useful in other scenarios. ``` using JET report_opt(Tuple{typeof(Artifacts._artifact_str), Module, String, Base.SubString{String}, String, Base.Dict{String, Any}, Base.SHA1, Base.BinaryPlatforms.Platform, Any}; target_modules=[Artifacts]) ``` is quite a bit cleaner with this.
…dows env variables (#52758) Should fix #52711. My analysis of the invalidation is as follows: We added code to cache the conversion to `cwstring` in env handling on Windows (#51371): ```julia const env_dict = IdDict{String, Vector{UInt16}}() function memoized_env_lookup(str::AbstractString) ... env_dict[str] = cwstring(str) ... end function access_env(onError::Function, str::AbstractString) var = memoized_env_lookup(str) ... end ``` Since `IdDict` has `@nospecialize` on `setindex!` we compile this method: ```julia setindex!(::IdDict{String, Vector{UInt16}}, ::Any, ::Any) ``` which has an edge to: ```julia convert(Type{Vector{Int64}}, Any}) ``` But then StaticArrays comes along and adds a method ```julia convert(::Type{Array{T, N}}, ::StaticArray) ``` which invalidates the `setindex!` (due to the edge to `convert`) which invalidates the whole env handling on Windows which causes 4k other methods downstream to be invalidated, in particular, the artifact string macro which causes a significant delay in the next jll package you load after loading StaticArrays. There should be no performance penalty to this since strings already does a hash for their `objectid`. (cherry picked from commit b7c24ed)
…dows env variables (JuliaLang#52758) Should fix JuliaLang#52711. My analysis of the invalidation is as follows: We added code to cache the conversion to `cwstring` in env handling on Windows (JuliaLang#51371): ```julia const env_dict = IdDict{String, Vector{UInt16}}() function memoized_env_lookup(str::AbstractString) ... env_dict[str] = cwstring(str) ... end function access_env(onError::Function, str::AbstractString) var = memoized_env_lookup(str) ... end ``` Since `IdDict` has `@nospecialize` on `setindex!` we compile this method: ```julia setindex!(::IdDict{String, Vector{UInt16}}, ::Any, ::Any) ``` which has an edge to: ```julia convert(Type{Vector{Int64}}, Any}) ``` But then StaticArrays comes along and adds a method ```julia convert(::Type{Array{T, N}}, ::StaticArray) ``` which invalidates the `setindex!` (due to the edge to `convert`) which invalidates the whole env handling on Windows which causes 4k other methods downstream to be invalidated, in particular, the artifact string macro which causes a significant delay in the next jll package you load after loading StaticArrays. There should be no performance penalty to this since strings already does a hash for their `objectid`. (cherry picked from commit b7c24ed)
There seems to be a regression in some package loading times and allocations on Windows that started between 1.10.0-rc1 and 1.10.0-rc2. Linux seems to be unaffected.
All binaries are official, from juliaup on Windows and https://julialang.org/downloads/ on Linux. Julia is started with
--startup-file=no
.Linux
Windows
Some packages does not show this, for example
OrdinaryDiffEq
. Also not shown byusing SparseArrays, StaticArrays
.The text was updated successfully, but these errors were encountered: