Skip to content

Performance regression in tuples getting copied to functions that only read from them. #15277

@KristofferC

Description

@KristofferC

There is a performance regression in what I believe is tuple indexing (now I believe it is function call overhead) now I believe it is tuples sometimes getting copied into functions that previously got passed by reference, from the giant codegen rewrite PR.

Test script (note the @noinline):

@noinline function get_idx_tuple(n::NTuple, i::Int)
    @inbounds v = n[i]
    return v
end


function bench{N, T}(tuple::NTuple{N, T})
    s = 0.0
    t_tup = @elapsed for n in 1:10^5
        for i in 1:N
            s += get_idx_tuple(tuple, i)
        end
    end
    return t_tup
end


tuple = (rand(75)...)

bench(tuple)

This typically looks like this for different sizes of the tuple:

tuple

Full bisect log: https://gist.github.com/KristofferC/1ba13fe374897e4f7f98

Relevant:

# possible first bad commit: [5c5d48369a1a8f9a5959699ec44cab393255d0c5] [wip codegen rewrite] fix another type information mismatch error in assignment
# possible first bad commit: [548075efe73083f6a58b97814ea558bdbc0db41d] [wip codegen rewrite] fix mixed-type intrinsic usage (such as `bswap(Float64)`)
# possible first bad commit: [322878d93879f81cdf3d6a783376ad149b10d65b] [wip codegen rewrite] fix select_value validation and missing value copy in variable assignment
# possible first bad commit: [e4dcff39221571b8fc59d25873de092edaf46768] [wip codegen rewrite] fix isVolatile marking and closure memloc allocation marking
# possible first bad commit: [8b98aa0fe4056915b69176c0eca23391a77f2f58] [wip codegen rewrite] fix marking of varinfo.value when type_is_ghost and recursive constant struct creation
# possible first bad commit: [ffc200620862e04d6e4d5b9363ea03130276deca] [wip codegen rewrite] cleanup closure env handling to occur early
# possible first bad commit: [ae1a623634aed1912b8fb12a624529f3108fe418] [wip codegen rewrite] use correct macro test for jl_is_immutable
# possible first bad commit: [fec6aa9048d2e54f3c178b379db96074f1d867be] [wip] codegen rewrite + rewrite intrinsics to accomodate

cc @vtjnash

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions