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

Long recompilation delay with finicky dependencies #21449

Closed
timholy opened this issue Apr 20, 2017 · 1 comment
Closed

Long recompilation delay with finicky dependencies #21449

timholy opened this issue Apr 20, 2017 · 1 comment
Labels
compiler:inference Type inference

Comments

@timholy
Copy link
Member

timholy commented Apr 20, 2017

Continuing from #21173 (comment). This is about as minimal as I was able to find (commenting almost anything out, including docstrings, eliminates the issue):

__precompile__(true)

module CoordTforms

using StaticArrays

abstract type Transformation end

#############################
### 2D Coordinate systems ###
#############################
"""
`Polar{T}(r::T, θ::T)` - 2D polar coordinates
"""
immutable Polar{T}
    r::T
    θ::T
end

"`PolarFromCartesian()` - transformation from `AbstractVector` of length 2 to `Polar` type"
immutable PolarFromCartesian <: Transformation; end
"`CartesianFromPolar()` - transformation from `Polar` type to `SVector{2}` type"
immutable CartesianFromPolar <: Transformation; end

function (::PolarFromCartesian)(x::AbstractVector)
    length(x) == 2 || error("Polar transform takes a 2D coordinate")

    Polar(sqrt(x[1]*x[1] + x[2]*x[2]), atan2(x[2], x[1]))
end

function (::CartesianFromPolar)(x::Polar)
    SVector(x.r * cos(x.θ), x.r * sin(x.θ))
end

Base.convert(::Type{Polar}, v::AbstractVector) = PolarFromCartesian()(v)
@inline Base.convert{V <: AbstractVector}(::Type{V}, p::Polar) = convert(V, CartesianFromPolar()(p))


#############################
### 3D Coordinate Systems ###
#############################
"""
Spherical(r, θ, ϕ) - 3D spherical coordinates
"""
immutable Spherical{T}
    r::T
    θ::T
    ϕ::T
end

end

Now if you do

julia> push!(LOAD_PATH, pwd())
3-element Array{Any,1}:
 "/home/tim/src/julia-0.6/usr/local/share/julia/site/v0.6"
 "/home/tim/src/julia-0.6/usr/share/julia/site/v0.6"      
 "/tmp"                                                   

julia> using CoordTforms

and then hit one key, TAB, and a second key, you'll see a very long delay.

@timholy
Copy link
Member Author

timholy commented Apr 20, 2017

It's worth noting that none of the code in CoordTforms uses StaticArrays. Yet if you comment out the using StaticArrays from inside CoordTforms.jl, the big delay goes away even if you load StaticArrays at the REPL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:inference Type inference
Projects
None yet
Development

No branches or pull requests

2 participants