Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mappedarrayreduce #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

jishnub
Copy link
Member

@jishnub jishnub commented Nov 24, 2020

A lazy version of mapreduce using MappedArrays to get around intermediate allocations (see julia/issues/38558). I'm not sure what to name the function, open to suggestions. The performance improvement is visible:

julia> x = randn(10240); y = similar(x);

julia> @btime mapreduce(==, +, $x, $y);
  22.145 μs (1 allocation: 10.19 KiB)

julia> @btime mappedarrayreduce(==, +, $x, $y);
  5.072 μs (0 allocations: 0 bytes)

@johnnychen94
Copy link
Member

johnnychen94 commented Nov 24, 2020

looks good, about the name, perhaps mapreducedarray?

Would be helpful to throw an explicit error for mappedarrayreduce(f, finv, op, A...) since there's a writable version mappedarray(f, finv, A...).

btw, we need to update docs and README.md, too.

@timholy
Copy link
Member

timholy commented Nov 24, 2020

If we can solve this by doing in JuliaLang/julia#38558 (comment), I'd very much prefer it to adding a new export here. But if that's not really feasible, then sure, let's do this. But I'd like to hold off a bit and see if someone tackles Generator performance, or at least digs deep enough to understand why it's slower.

@JeffBezanson
Copy link

I don't think "lazy" is accurate here; it just computes the reduction. Whether there is an intermediate array is not observable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants