Skip to content

Optimized methods for mapreduce(f, vcat, xs) and mapreduce(f, hcat, xs) #31137

@oxinabox

Description

@oxinabox

given we had #21672
which makes reduce(vcat and reduce(hcat fast.

I had assumed it also applied to mapreduce of these operations.
But it clearly does not.

julia> @btime reduce(vcat, $datas)
  87.049 μs (2 allocations: 117.27 KiB)

julia> @btime mapreduce(identity, vcat, $datas);
  5.372 ms (10005 allocations: 37.04 MiB)

julia> @btime reduce(vcat, map(identity, $datas));
  93.212 μs (5 allocations: 156.42 KiB)

Right now, if the 2nd arg is vcat or hcat it is faster to call reduce(op, map(f, xs)) than mapreduce(f, op, xs).
And maybe that would be a solid first move to fix this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    foldsum, maximum, reduce, foldl, etc.performanceMust go faster

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions