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

Julia 1.0.5 large memory usage compiling module #38634

Closed
odow opened this issue Dec 1, 2020 · 2 comments
Closed

Julia 1.0.5 large memory usage compiling module #38634

odow opened this issue Dec 1, 2020 · 2 comments

Comments

@odow
Copy link
Contributor

odow commented Dec 1, 2020

JuMP is failing tests on GitHub Actions, Julia 1.0.5 (but notably, not on Julia 1.5) due to the v1.0 release of StaticArrays. I've simplified it to the one below. Here's the relevant issue jump-dev/JuMP.jl#2390.

The underlying issue is that running using Foo takes more than 4 GB of memory, and so GitHub Actions spikes the VM.
Compiling with Julia 1.5 uses ~42 MiB.

I'm not sure what the resolution is. In the interim, we can cap our StaticArrays version. But this is fairly brittle. If 1.6 becomes LTS soon-ish, we could also just drop support for 1.0 and forget about this.

#!/bin/bash

rm -rf src
rm Project.toml
rm Manifest.toml

mkdir src

echo """name = \"Foo\"

[deps]
LinearAlgebra = \"37e2e46d-f89d-539d-b4ee-838fcccc9c8e\"""" > Project.toml

echo """module Foo

import LinearAlgebra

abstract type A end
const B = AbstractMatrix{<:A}
const C = LinearAlgebra.Adjoint

LinearAlgebra.mul!(::B, ::Any, ::C) = 1
LinearAlgebra.mul!(::B, ::C, ::Any) = 2
LinearAlgebra.mul!(::B, ::Any, ::Any) = 3

abstract type D{M, T} <: AbstractMatrix{T} end
const D2{M, N, T} = D{Tuple{M, N}, T}

E{T} = Union{
    D{<:Int, T},
    D{<:Any, T},
    LinearAlgebra.Transpose{T,           <:D2{<:Any, <:Any, T}},
    LinearAlgebra.Adjoint{T,             <:D{<:Any, T}},
    LinearAlgebra.Symmetric{T,           <:D{<:Any, T}},
    LinearAlgebra.Hermitian{T,           <:D{<:Any, T}},
    LinearAlgebra.Diagonal{T,            <:D{<:Any, T}},
    LinearAlgebra.UpperTriangular{T,     <:D{<:Any, T}},
    LinearAlgebra.LowerTriangular{T,     <:D{<:Any, T}},
    LinearAlgebra.UnitUpperTriangular{T, <:D{<:Any, T}},
    LinearAlgebra.UnitLowerTriangular{T, <:D{<:Any, T}},
}

LinearAlgebra.mul!(::E{T1}, ::E{T2}, ::E{T3}) where {T1,T2,T3} = 4

end""" > src/Foo.jl

julia --project=. -e 'import Pkg; Pkg.instantiate(); Pkg.status(Pkg.PKGMODE_MANIFEST)'
julia --project=. -e 'using InteractiveUtils; versioninfo()'
rm -rf ~/.julia/compiled/v1.0/Foo
julia --project=. -e '@time using Foo'

Here's the output

% ./foo.sh
  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
 Resolving package versions...
  Updating `/private/tmp/julia/Project.toml`
  [37e2e46d] + LinearAlgebra 
  Updating `/private/tmp/julia/Manifest.toml`
  [8f399da3] + Libdl 
  [37e2e46d] + LinearAlgebra 
Project Foo v0.0.0
    Status `/private/tmp/julia/Manifest.toml`
  [8f399da3] Libdl 
  [37e2e46d] LinearAlgebra 
Julia Version 1.0.5
Commit 3af96bcefc (2019-09-09 19:06 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.6.0)
  CPU: Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, skylake)
 12.724876 seconds (87.25 M allocations: 3.983 GiB, 3.31% gc time)

cc @mlubin

odow added a commit to jump-dev/JuMP.jl that referenced this issue Dec 1, 2020
…nd a compiler bug

The upstream issue is logged at: JuliaLang/julia#38634

StaticArrays should be removed as a direct dependency once support for Julia 1.0.x is
removed.
@odow odow changed the title Julia 1.0.5, Linux, OutOfMemory error Julia 1.0.5 large memory usage compiling module Dec 1, 2020
@odow
Copy link
Contributor Author

odow commented Dec 1, 2020

This may not be a bug, just some optimizations of large unions that haven't been/won't be back ported to 1.0.x, an so probably requires a fix on our end.

Feel free to close if this seems correct.

odow added a commit to jump-dev/JuMP.jl that referenced this issue Dec 2, 2020
Add StaticArrays as a dependency and cap maximum version to work-around a compiler bug.

The upstream issues are logged at: 
- JuliaLang/julia#38634
- JuliaArrays/StaticArrays.jl#857

StaticArrays should be removed as a direct dependency once support for Julia 1.0.x is
removed.
@odow
Copy link
Contributor Author

odow commented Dec 6, 2020

Closed by JuliaArrays/StaticArrays.jl#859

@odow odow closed this as completed Dec 6, 2020
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

No branches or pull requests

1 participant