Skip to content

How much faster can we make sum with skipmissing? #40028

@pdeffebach

Description

@pdeffebach

Just did some benchmarking about sum with skipmissing. It's slower than i expected, even with skipmissing's optimized reduce infrastructure.

julia> x = [rand() < .2 ? missing : rand() for i in 1:100_000];

julia> y = collect(skipmissing(x));

julia> using BenchmarkTools;

julia> @btime (sum ∘ skipmissing)($x);
  229.778 μs (6 allocations: 96 bytes)

julia> @btime (sum ∘ skipmissing)($x);
  227.911 μs (5 allocations: 80 bytes)

julia> @btime sum($y);
  12.180 μs (0 allocations: 0 bytes)

julia> @btime sum($y);
  12.185 μs (0 allocations: 0 bytes)

julia> sum2(x) = sum(skipmissing(x));

julia> @btime sum2($x);
  228.483 μs (5 allocations: 80 bytes)

julia> @btime sum2($x);
  229.343 μs (5 allocations: 80 bytes)

Is there anything to make this faster?

Metadata

Metadata

Assignees

No one assigned

    Labels

    missing dataBase.missing and related functionalityperformanceMust go faster

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions