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

Backports for 1.10.4 #54416

Open
wants to merge 10 commits into
base: release-1.10
Choose a base branch
from
Open

Backports for 1.10.4 #54416

wants to merge 10 commits into from

Conversation

goerz and others added 9 commits April 22, 2024 20:26
This shouldn't have any cost on smaller images because the only thing
that gets put into ldata is the system image data, which is only
reference via `dlsym`. This allows for images larger than 2gb (tested by
putting a 2gb array in the base image)

I did not test how this might be handled in other platforms (Windows
doesn't support it).

(cherry picked from commit 0f04b33)
This reduces dynamic dispatch and makes JET happier.
Testing on v1.11:
```julia
julia> import LinearAlgebra: checksquare

julia> using JET

julia> @report_opt checksquare(rand(2,2), rand(2,2))
═════ 4 possible errors found ═════
┌ checksquare(::Matrix{Float64}, ::Matrix{Float64}) @ LinearAlgebra /cache/build/builder-amdci4-1/julialang/julia-release-1-dot-11/usr/share/julia/stdlib/v1.11/LinearAlgebra/src/LinearAlgebra.jl:307
│┌ string(::String, ::Tuple{Int64, Int64}) @ Base ./strings/io.jl:189
││┌ print_to_string(::String, ::Tuple{Int64, Int64}) @ Base ./strings/io.jl:150
│││┌ _unsafe_take!(io::IOBuffer) @ Base ./iobuffer.jl:494
││││┌ wrap(::Type{Array}, m::MemoryRef{UInt8}, l::Int64) @ Base ./array.jl:3101
│││││ failed to optimize due to recursion: wrap(::Type{Array}, ::MemoryRef{UInt8}, ::Int64)
││││└────────────────────
│││┌ print_to_string(::String, ::Vararg{Any}) @ Base ./strings/io.jl:143
││││ runtime dispatch detected: Base._str_sizehint(%17::Any)::Int64
│││└────────────────────
│││┌ print_to_string(::String, ::Vararg{Any}) @ Base ./strings/io.jl:148
││││ runtime dispatch detected: print(%59::IOBuffer, %97::Any)::Any
│││└────────────────────
│││┌ string(::String, ::Int64, ::String, ::Tuple{Int64}, ::String, ::Int64, ::String, ::Int64, ::String) @ Base ./strings/io.jl:189
││││ failed to optimize due to recursion: string(::String, ::Int64, ::String, ::Tuple{Int64}, ::String, ::Int64, ::String, ::Int64, ::String)
│││└────────────────────

julia> function checksquare(A...) # This PR
                  sizes = Int[]
                  for a in A
                      size(a,1)==size(a,2) || throw(DimensionMismatch(lazy"matrix is not square: dimensions are $(size(a))"))
                      push!(sizes, size(a,1))
                  end
                  return sizes
              end
checksquare (generic function with 2 methods)

julia> @report_opt checksquare(rand(2,2), rand(2,2))
No errors detected

```

(cherry picked from commit d505c8c)
This reverts part of 67b8ac0
(#47596 (comment)).
That change broke `make install` from tarballs due to building docs
again, which fails as there's no git repo (and also requires Internet
access to download UnicodeData.txt.

Fixes #54037.

(cherry picked from commit d6dda7c)
…k adj/trans (#54151)

Fixes the following issue on master, where the zero element is computed
incorrectly (but subsequent terms are computed correctly):
```julia
julia> using LinearAlgebra

julia> x = [1 2 3; 4 5 6];

julia> A = reshape([x,2x,3x,4x],2,2);

julia> b = fill(x, 2);

julia> A' * b
ERROR: DimensionMismatch: matrix A has axes (Base.OneTo(2),Base.OneTo(3)), matrix B has axes (Base.OneTo(2),Base.OneTo(3))
Stacktrace:
  [1] _generic_matmatmul!(C::Matrix{Int64}, A::Matrix{Int64}, B::Matrix{Int64}, _add::LinearAlgebra.MulAddMul{true, true, Bool, Bool})
    @ LinearAlgebra ~/.julia/juliaup/julia-nightly/share/julia/stdlib/v1.12/LinearAlgebra/src/matmul.jl:849
  [2] generic_matmatmul!
    @ ~/.julia/juliaup/julia-nightly/share/julia/stdlib/v1.12/LinearAlgebra/src/matmul.jl:834 [inlined]
  [3] _mul!
    @ ~/.julia/juliaup/julia-nightly/share/julia/stdlib/v1.12/LinearAlgebra/src/matmul.jl:287 [inlined]
  [4] mul!
    @ ~/.julia/juliaup/julia-nightly/share/julia/stdlib/v1.12/LinearAlgebra/src/matmul.jl:285 [inlined]
  [5] mul!
    @ ~/.julia/juliaup/julia-nightly/share/julia/stdlib/v1.12/LinearAlgebra/src/matmul.jl:253 [inlined]
  [6] *
    @ ~/.julia/juliaup/julia-nightly/share/julia/stdlib/v1.12/LinearAlgebra/src/matmul.jl:114 [inlined]
  [7] _generic_matvecmul!(C::Vector{Matrix{…}}, tA::Char, A::Matrix{Matrix{…}}, B::Vector{Matrix{…}}, _add::LinearAlgebra.MulAddMul{true, true, Bool, Bool})
    @ LinearAlgebra ~/.julia/juliaup/julia-nightly/share/julia/stdlib/v1.12/LinearAlgebra/src/matmul.jl:797
  [8] generic_matvecmul!
    @ ~/.julia/juliaup/julia-nightly/share/julia/stdlib/v1.12/LinearAlgebra/src/matmul.jl:755 [inlined]
  [9] _mul!
    @ ~/.julia/juliaup/julia-nightly/share/julia/stdlib/v1.12/LinearAlgebra/src/matmul.jl:73 [inlined]
 [10] mul!
    @ ~/.julia/juliaup/julia-nightly/share/julia/stdlib/v1.12/LinearAlgebra/src/matmul.jl:70 [inlined]
 [11] mul!
    @ ~/.julia/juliaup/julia-nightly/share/julia/stdlib/v1.12/LinearAlgebra/src/matmul.jl:253 [inlined]
 [12] *(A::Adjoint{Adjoint{Int64, Matrix{Int64}}, Matrix{Matrix{Int64}}}, x::Vector{Matrix{Int64}})
    @ LinearAlgebra ~/.julia/juliaup/julia-nightly/share/julia/stdlib/v1.12/LinearAlgebra/src/matmul.jl:60
 [13] top-level scope
    @ REPL[10]:1
Some type information was truncated. Use `show(err)` to see complete types.
```
After this PR,
```julia
julia> A' * b
2-element Vector{Matrix{Int64}}:
 [51 66 81; 66 87 108; 81 108 135]
 [119 154 189; 154 203 252; 189 252 315]
```

(cherry picked from commit 2b878f0)
Fixes #54225

(cherry picked from commit b35d308)
Should fix #54247.

- Before:
```
Julia Version 1.12.0-DEV.410
Commit 0735854* (2024-04-25 14:35 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin23.4.0)
  CPU: 12 × Apple M2 Max
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, apple-m2)
Threads: 8 default, 0 interactive, 4 GC (on 8 virtual cores)
***** Vector *****
serial: 0.607365 seconds (3 allocations: 381.470 MiB, 0.22% gc time)
serial: 0.597241 seconds (3 allocations: 381.470 MiB, 1.18% gc time)
serial: 0.589679 seconds (3 allocations: 381.470 MiB, 1.21% gc time)
serial: 0.581607 seconds (3 allocations: 381.470 MiB, 0.97% gc time)
serial: 0.578147 seconds (3 allocations: 381.470 MiB, 0.96% gc time)
serial: 0.577399 seconds (3 allocations: 381.470 MiB, 0.94% gc time)
serial: 0.564742 seconds (3 allocations: 381.470 MiB, 0.93% gc time)
serial: 0.591733 seconds (3 allocations: 381.470 MiB, 0.90% gc time)
serial: 0.565088 seconds (3 allocations: 381.470 MiB, 0.97% gc time)
serial: 0.556800 seconds (3 allocations: 381.470 MiB, 0.94% gc time)
parallel: 0.563600 seconds (3.33 k allocations: 381.640 MiB, 0.10% gc time, 0.94% compilation time)
parallel: 0.564652 seconds (9 allocations: 381.470 MiB, 1.02% gc time)
parallel: 0.581996 seconds (9 allocations: 381.470 MiB, 0.95% gc time)
parallel: 0.576503 seconds (9 allocations: 381.470 MiB, 0.90% gc time)
parallel: 0.565595 seconds (9 allocations: 381.470 MiB, 0.94% gc time)
parallel: 0.575850 seconds (9 allocations: 381.470 MiB, 0.95% gc time)
parallel: 0.604621 seconds (9 allocations: 381.470 MiB, 0.91% gc time)
parallel: 0.578168 seconds (9 allocations: 381.470 MiB, 0.91% gc time)
parallel: 0.600408 seconds (9 allocations: 381.470 MiB, 0.92% gc time)
parallel: 0.576794 seconds (9 allocations: 381.470 MiB, 0.95% gc time)

***** Astruct *****
serial: 0.659020 seconds (3 allocations: 762.940 MiB, 0.18% gc time)
serial: 0.674630 seconds (3 allocations: 762.940 MiB, 1.63% gc time)
serial: 0.670532 seconds (3 allocations: 762.940 MiB, 1.86% gc time)
serial: 0.682483 seconds (3 allocations: 762.940 MiB, 1.57% gc time)
serial: 0.673673 seconds (3 allocations: 762.940 MiB, 1.62% gc time)
serial: 0.652506 seconds (3 allocations: 762.940 MiB, 1.72% gc time)
serial: 0.667336 seconds (3 allocations: 762.940 MiB, 1.69% gc time)
serial: 0.659686 seconds (3 allocations: 762.940 MiB, 1.76% gc time)
serial: 0.673387 seconds (3 allocations: 762.940 MiB, 1.73% gc time)
serial: 0.668930 seconds (3 allocations: 762.940 MiB, 1.67% gc time)
parallel: 0.646382 seconds (3.42 k allocations: 763.114 MiB, 0.09% gc time, 0.77% compilation time)
parallel: 0.665347 seconds (9 allocations: 762.940 MiB, 1.70% gc time)
parallel: 0.676490 seconds (9 allocations: 762.940 MiB, 1.84% gc time)
parallel: 22.732728 seconds (9 allocations: 762.940 MiB, 97.12% gc time)
parallel: 22.668091 seconds (9 allocations: 762.940 MiB, 97.15% gc time)
parallel: 0.629117 seconds (9 allocations: 762.940 MiB)
parallel: 22.948883 seconds (9 allocations: 762.940 MiB, 97.26% gc time)
parallel: 0.629834 seconds (9 allocations: 762.940 MiB)
parallel: 1.108239 seconds (9 allocations: 762.940 MiB, 42.54% gc time)
parallel: 0.648325 seconds (9 allocations: 762.940 MiB)
```

- After:
```
Julia Version 1.12.0-DEV.410
Commit 0735854* (2024-04-25 14:35 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin23.4.0)
  CPU: 12 × Apple M2 Max
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, apple-m2)
Threads: 8 default, 0 interactive, 4 GC (on 8 virtual cores)
***** Vector *****
serial: 0.600418 seconds (3 allocations: 381.470 MiB, 0.20% gc time)
serial: 0.613808 seconds (3 allocations: 381.470 MiB, 1.17% gc time)
serial: 0.596335 seconds (3 allocations: 381.470 MiB, 1.21% gc time)
serial: 0.589423 seconds (3 allocations: 381.470 MiB, 0.92% gc time)
serial: 0.621845 seconds (3 allocations: 381.470 MiB, 0.89% gc time)
serial: 0.580239 seconds (3 allocations: 381.470 MiB, 0.94% gc time)
serial: 0.604881 seconds (3 allocations: 381.470 MiB, 0.90% gc time)
serial: 0.581353 seconds (3 allocations: 381.470 MiB, 0.95% gc time)
serial: 0.603317 seconds (3 allocations: 381.470 MiB, 0.89% gc time)
serial: 0.599634 seconds (3 allocations: 381.470 MiB, 0.90% gc time)
parallel: 0.589694 seconds (3.33 k allocations: 381.640 MiB, 0.10% gc time, 1.01% compilation time)
parallel: 0.600812 seconds (9 allocations: 381.470 MiB, 0.98% gc time)
parallel: 0.610956 seconds (9 allocations: 381.470 MiB, 5.13% gc time)
parallel: 0.677189 seconds (9 allocations: 381.470 MiB, 14.26% gc time)
parallel: 0.571583 seconds (9 allocations: 381.470 MiB, 1.80% gc time)
parallel: 0.742617 seconds (9 allocations: 381.470 MiB, 17.81% gc time)
parallel: 0.624541 seconds (9 allocations: 381.470 MiB, 5.02% gc time)
parallel: 0.723963 seconds (9 allocations: 381.470 MiB, 14.03% gc time)
parallel: 0.609618 seconds (9 allocations: 381.470 MiB)
parallel: 0.708227 seconds (9 allocations: 381.470 MiB, 16.29% gc time)

***** Astruct *****
serial: 0.627853 seconds (3 allocations: 762.940 MiB)
serial: 0.647795 seconds (3 allocations: 762.940 MiB, 2.14% gc time)
serial: 0.640387 seconds (3 allocations: 762.940 MiB, 1.91% gc time)
serial: 0.698194 seconds (3 allocations: 762.940 MiB, 1.73% gc time)
serial: 0.673018 seconds (3 allocations: 762.940 MiB, 1.68% gc time)
serial: 0.641571 seconds (3 allocations: 762.940 MiB, 1.79% gc time)
serial: 0.669718 seconds (3 allocations: 762.940 MiB, 1.65% gc time)
serial: 0.661993 seconds (3 allocations: 762.940 MiB, 1.73% gc time)
serial: 0.661846 seconds (3 allocations: 762.940 MiB, 1.85% gc time)
serial: 0.661637 seconds (3 allocations: 762.940 MiB, 1.73% gc time)
parallel: 0.645750 seconds (3.42 k allocations: 763.114 MiB, 0.09% gc time, 0.83% compilation time)
parallel: 0.653331 seconds (9 allocations: 762.940 MiB, 1.92% gc time)
parallel: 0.673813 seconds (9 allocations: 762.940 MiB, 1.80% gc time)
parallel: 0.720503 seconds (9 allocations: 762.940 MiB, 9.40% gc time)
parallel: 0.889651 seconds (9 allocations: 762.940 MiB, 25.33% gc time)
parallel: 0.644618 seconds (9 allocations: 762.940 MiB, 2.26% gc time)
parallel: 0.919954 seconds (9 allocations: 762.940 MiB, 28.99% gc time)
parallel: 0.750246 seconds (9 allocations: 762.940 MiB, 9.03% gc time)
parallel: 0.767282 seconds (9 allocations: 762.940 MiB, 10.55% gc time)
parallel: 0.899596 seconds (9 allocations: 762.940 MiB, 25.69% gc time)
```

(cherry picked from commit dc0a477)
…nts (#54363)

The added MWE has been broken since 1.8.
The intersect result still looks quite unsoundness, but at least stack
overflow get fixed.

close #54356

(cherry picked from commit e47fedd)
@KristofferC KristofferC added the kind:release Release management and versioning. label May 8, 2024
@IanButterworth
Copy link
Sponsor Member

To get the heapsnapshot fixes in I think these are all needed

Which I tried but they're not very clean backports. I think someone familiar with GC would be better suited to handle them.

@fingolfin
Copy link
Contributor

It would be great to also get #53815 into 1.10.4. It requires (IMHO straightforward) manual resolution of the merge but it is easy enough, I can provide a PR if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:release Release management and versioning.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet