-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
performanceMust go fasterMust go fasterregressionRegression in behavior compared to a previous versionRegression in behavior compared to a previous versionregression 1.9Regression in the 1.9 releaseRegression in the 1.9 release
Description
Compared to v1.8:
- v1.9.2 has a regression where
a.xxallocates (whereasgetfield(a, :xx)doesn't) - v1.10.0-beta1 has a regression where both
a[1].xxandgetfield(a[1], :xx)allocate whenais a a tuple
The following script should show the problem:
using BenchmarkTools
struct XX
xx::Vector{Int}
end
const XXs = XX(Int[])
get1() = length(getfield(XXs, :xx))
get2() = length(XXs.xx)
const YYs = (XX(Int[]),)
get3() = length(getfield(YYs[1], :xx))
get4() = length(YYs[1].xx)
@btime get1()
@btime get2()
@btime get3()
@btime get4()
nothingThen:
julia> include("tmp/julia/getfield.jl") # v1.8.5
1.923 ns (0 allocations: 0 bytes)
1.924 ns (0 allocations: 0 bytes)
1.923 ns (0 allocations: 0 bytes)
1.923 ns (0 allocations: 0 bytes)
julia> include("tmp/julia/getfield.jl") # v1.9.2
1.923 ns (0 allocations: 0 bytes)
12.877 ns (1 allocation: 16 bytes)
2.134 ns (0 allocations: 0 bytes)
12.927 ns (1 allocation: 16 bytes)
julia> include("tmp/julia/getfield.jl") # v1.10.0-beta1
1.953 ns (0 allocations: 0 bytes)
2.815 ns (0 allocations: 0 bytes)
15.269 ns (1 allocation: 16 bytes)
17.970 ns (1 allocation: 16 bytes)
Metadata
Metadata
Assignees
Labels
performanceMust go fasterMust go fasterregressionRegression in behavior compared to a previous versionRegression in behavior compared to a previous versionregression 1.9Regression in the 1.9 releaseRegression in the 1.9 release