Skip to content

Regression in memory allocs when forming NTuple  #41512

Closed
@jw3126

Description

@jw3126

The following code allocates on master and 1.7beta2, but does not allocate on 1.6:

Tuple3(itr) = NTuple{3, Float64}(itr)::NTuple{3,Float64}

function doit(itr)
    for x in itr
        Tuple3(x)
    end
end

itr = [randn(3) for _ in 1:10000]
doit(itr)
@time doit(itr)
master:  0.021418 seconds (120.00 k allocations: 2.899 MiB)
julia 1.6:  0.000032 seconds

This lead to regressions in two packages for me:
https://github.com/jw3126/VoxelRayTracers.jl/blob/master/src/core.jl#L71
https://github.com/jw3126/LinearInterpolations.jl/blob/master/src/LinearInterpolations.jl#L407
https://github.com/jw3126/LinearInterpolations.jl/blob/master/test/test_LinearInterpolations.jl#L259

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceMust go fasterregressionRegression in behavior compared to a previous version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions