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
Performance regression in 1.0.1 #29464
Comments
I'm bisecting |
|
|
Oops! I closed the issue by a misclick. I wanted to say: I do not know if the issue has been identified, but if this may help here is a simplified snippet which still shows exactly the same problem:
|
Here is a way to generate arbitrary slowdown: N = 10000
a = collect(1:N)
b = collect(2:N+1)
function foo(elts::Vararg{Vector{Int}})
ee=collect(elts)
for i in 1:length(ee[1])-1
f = w -> w[i] > w[i+1]
all(f,ee)
end
end
using BenchmarkTools
@btime foo($a,$b) 0.7: julia> @btime foo($a,$b)
12.316 μs (2 allocations: 128 bytes) 1.0.1 julia> @btime foo($a,$b)
3.672 ms (38979 allocations: 765.39 KiB) Profiling shows that we spend a lot in the runtime.
|
Ok, it is a code specialization heuristic. Changing the function declaration from foo(elts::Vararg{Vector{Int}}) to foo(elts::Vararg{Vector{Int}, N}) where {N} fixes it: julia> @btime foo($a,$b)
11.868 μs (1 allocation: 96 bytes) |
Is this more or less what is described here: https://docs.julialang.org/en/v1/devdocs/functions/#Compiler-efficiency-issues-1? |
I guess, don't know how it is related to #29112 though. Or if I just worked around the problem with the extra specialization but the original issue is not fixed. |
The julia> code_warntype(Base.IteratorEltype, Tuple{Tuple{Vararg{Vector{Int}}}})
Body::Union{EltypeUnknown, HasEltype}
123 1 ─ %1 = (Base.typeof)(x)::Type{#s55} where #s55<:Tuple{Vararg{Array{Int64,1},N} where N} │
│ %2 = (isa)(%1, Type{Union{}})::Bool │
└── goto #3 if not %2 │
2 ─ goto #4 │
3 ─ %5 = (Base.IteratorEltype)(%1)::Union{EltypeUnknown, HasEltype} │
└── goto #4 │
4 ┄ %7 = φ (#2 => $(QuoteNode(Base.EltypeUnknown())), #3 => %5)::Union{EltypeUnknown, HasEltype} │
└── return %7 Removing this method, added in #29112: Line 129 in 1968b23
we get: julia> code_warntype(Base.IteratorEltype, Tuple{Tuple{Vararg{Vector{Int}}}})
Body::Base.HasEltype
123 1 ─ return $(QuoteNode(Base.HasEltype())) and performance of the original example is back at 0.7 levels. Not sure what to do here. |
@JeffBezanson, any ideas how to do better here? |
Fixed #29548 |
One of my programs which took 1mn on 1.0.0 takes 5mn on 1.0.1
I tracked at least part of the problem to the following code snippet:
On 1.0.0
On 1.0.1:
Does anyone know what’s happening here?
The text was updated successfully, but these errors were encountered: