Skip to content
This repository has been archived by the owner on Feb 9, 2020. It is now read-only.

Bad performance on multivariable functions. #2

Closed
adamczykm opened this issue Nov 26, 2014 · 3 comments
Closed

Bad performance on multivariable functions. #2

adamczykm opened this issue Nov 26, 2014 · 3 comments

Comments

@adamczykm
Copy link

Have a look:
a=randn(5000000);

@time(reduce((x,y) -> x,a))
elapsed time: 0.250185444 seconds (60000812 bytes allocated, 51.42% gc time)
0.5564212271634134

@time(reduce(@anon((x,y) -> x),a))
elapsed time: 0.815615445 seconds (120012708 bytes allocated, 35.23% gc time)
0.5564212271634134

@timholy
Copy link
Owner

timholy commented Nov 26, 2014

I bet it's just that there needs to be a specialized version of reduce. Only map and map! have been implemented. Care to contribute reduce?

But there also seems to be a dispatch issue, I'm not seeing it call the specialized versions in FastAnonymous:

julia> @which map((@anon x->x), a)
map(f::Union(DataType,Function),A::AbstractArray{T,N}) at abstractarray.jl:1303

when instead it should be calling this method.

So if you contribute reduce, you could call it reduce_fa or something. Meanwhile I'll try to figure out the dispatch problem.

@adamczykm
Copy link
Author

I'll be happy to contribute as soon as I get some spare time. Lots of things are happening to me right now. I'll check if it's still an issue on January.

@timholy
Copy link
Owner

timholy commented May 6, 2015

This is fixed in julia 0.4 because of JuliaLang/julia#10314. I'll close the issue, but note that on the 0.3 version of this package it would still require a pull request to implement efficient reduce. If you decide to do this, I can create a 0.3 branch; as it is, further development of this package on 0.3 is frozen.

@timholy timholy closed this as completed May 6, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants