-
Notifications
You must be signed in to change notification settings - Fork 9
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
tmap(f, arr)
is slower than tmap(f, OutputEltype, arr)
or tmap!(f, output, arr)
#131
Comments
Yes, this is expected, although the result appears to be quite a bit worse on your machine than mine: julia> let x = rand(1_000_000)
@btime map(log, $x)
@btime tmap(log, $x)
@btime foo($x)
end;
4.012 ms (3 allocations: 7.63 MiB)
1.809 ms (223 allocations: 28.47 MiB)
683.822 μs (58 allocations: 7.63 MiB)
julia> let x = rand(10_000_000)
@btime map(log, $x)
@btime tmap(log, $x)
@btime foo($x)
end;
45.237 ms (3 allocations: 76.29 MiB)
27.756 ms (222 allocations: 354.39 MiB)
9.755 ms (58 allocations: 76.30 MiB) What's going on here is that The easiest way around this would be to just provide the julia> let x = rand(1_000_000)
@btime tmap(log, Float64, $x)
end;
701.749 μs (59 allocations: 7.63 MiB)
julia> let x = rand(10_000_000)
@btime tmap(log, Float64, $x)
end;
10.808 ms (59 allocations: 76.30 MiB) which basically does the same thing as your This is mentioned in the docstring of
but maybe this could have been more explicit. |
That said, I do think there's room here for us to make |
tmap(f, arr)
is slower than tmap(f, OutputEltype, arr)
or tmap!(f, output, arr)
The idea would just be that inferred_output_eltype = Core.Compiler.return_type(f, Tuple{eltype(x)})
if isconcretetype(inferred_output_eltype)
tmap(f, inferred_output_eltype, x)
else
# do what we currently do
end which is a pretty easy change. The main thing is that we have to carefully go through the internal call-chain and carefully make sure that we're not going to encounter any jumps in world-age that could cause the invocation of |
Got it. Many thanks!! Great package btw. |
It seems that
tmap
is substantially slower than creating a variableoutput
and update it usingtmap!
. Is this behavior expected or a bug?in my machine gives
The text was updated successfully, but these errors were encountered: