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

Potentially address performance regression with Julia 1.9 #1148

Closed
BioTurboNick opened this issue Mar 27, 2023 · 3 comments · Fixed by #1157
Closed

Potentially address performance regression with Julia 1.9 #1148

BioTurboNick opened this issue Mar 27, 2023 · 3 comments · Fixed by #1157
Labels
performance runtime performance

Comments

@BioTurboNick
Copy link
Contributor

There's a performance issue with Julia 1.9-rc. When using the constructors with a length determined at runtime, Julia falls back on dynamic dispatch.

using BenchmarkTools
using StaticArrays
const xx = [1; 2]
@noinline function e(x)
    k = length(x)
    SVector{k}(x)
end

@btime e(xx) 
# 1.9-rc1: 27.898 μs (31 allocations: 2.66 KiB)
# 1.8.5: 762.239 ns (10 allocations: 544 bytes)

According to JuliaLang/julia#49145, there may be changes in StaticArrays that would work around this issue.

@mateuszbaran mateuszbaran added the performance runtime performance label Mar 27, 2023
@N5N3
Copy link
Contributor

N5N3 commented Mar 28, 2023

It should be noticed that this is caused by the @propagate_inbounds macro, which makes the constuctor inlined unstablely.
I tried some other constructor in convert.jl. Looks like construct_type is heavy enough to block the inliner so perhaps we only need this specific fix.

@BioTurboNick
Copy link
Contributor Author

Sorry, what's the specific fix you have in mind? I'd do a PR but not quite sure what you mean.

@N5N3
Copy link
Contributor

N5N3 commented Apr 19, 2023

We have some similar pattern in convert.jl, but JuliaLang/julia#49145 (comment) is enough as all other constructors are not marked as @inline or @propagate_inbounds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance runtime performance
Projects
None yet
3 participants