Skip to content

Regression in performance of sum on Broadcasted with small Union eltype #39425

Closed

Description

The performance of sum(Base.Broadcast.Broadcasted(*, (x, z))) when z has eltype Union{Float64, Missing} regressed dramatically between Julia 1.3 and 1.4. It improved again in 1.5 but it's still much slower on master than on 1.3.

On Julia 1.3.1:

julia> using BenchmarkTools

julia> using LinearAlgebra

julia> x = rand(10_000);

julia> z = Vector{Union{Float64, Missing}}(x);

julia> f(A, w) = sum(Base.Broadcast.Broadcasted(*, (A, w)))
f (generic function with 1 method)

julia> @btime f(x, z);
  31.150 μs (11 allocations: 240 bytes)

On 1.4.2:

julia> @btime f(x, z);
  2.070 ms (40004 allocations: 1.07 MiB)

On master:

julia> @btime f(x, z);
  941.751 μs (40002 allocations: 1.07 MiB)

Cc: @tkf. Found while investigating JuliaStats/StatsBase.jl#518 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    broadcastApplying a function over a collectionmissing dataBase.missing and related functionalityperformanceMust 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