-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
ismissing(x) much slower than x === missing #27681
Comments
What if you change the definition to |
Probably a good idea (since it assists with more optimal inlining), but won't affect inference (I think we have a issue open about improving that) |
What's the inference issue? |
One of the points of having Though I guess having this definition as a fallback would be OK if that's more efficient. I'll let @vtjnash decide whether it's a good idea. |
|
Timings regressed between 1.5.0 and master:
julia> @btime mysum(X1);
5.581 ms (1 allocation: 16 bytes)
julia> @btime mysum(X2);
6.224 ms (1 allocation: 16 bytes)
julia> @btime mysum(X3);
6.294 ms (1 allocation: 16 bytes)
julia> @btime mysum2(X1);
5.558 ms (1 allocation: 16 bytes)
julia> @btime mysum2(X2);
22.348 ms (1 allocation: 16 bytes)
julia> @btime mysum2(X3);
22.258 ms (1 allocation: 16 bytes)
julia> @btime mysum(X1);
5.941 ms (1 allocation: 16 bytes)
julia> @btime mysum(X2);
6.261 ms (1 allocation: 16 bytes)
julia> @btime mysum(X3);
6.232 ms (1 allocation: 16 bytes)
julia> @btime mysum2(X1);
5.982 ms (1 allocation: 16 bytes)
julia> @btime mysum2(X2);
37.539 ms (1 allocation: 16 bytes)
julia> @btime mysum2(X3);
45.600 ms (1 allocation: 16 bytes) EDIT: filed #37476 as that's probably separate from the root issue discussed here. |
Thanks to @aviatesk's work at #38905, this is now fixed! For reference, here are the results of the benchmarks above on master: julia> @btime mysum(X1);
6.282 ms (1 allocation: 16 bytes)
julia> @btime mysum(X2);
6.370 ms (1 allocation: 16 bytes)
julia> @btime mysum(X3);
6.343 ms (1 allocation: 16 bytes)
julia> @btime mysum2(X1);
5.957 ms (1 allocation: 16 bytes)
julia> @btime mysum2(X2);
6.757 ms (1 allocation: 16 bytes)
julia> @btime mysum2(X3);
6.703 ms (1 allocation: 16 bytes) Though cases that were already fast are about 10% slower than on 1.5, but nothing dramatic. |
Since #27651 a loop involving
x === missing
can be very fast, but using the more genericismissing(x)
leads to much less efficient code being generated. Apparently, the compiler isn't able to detect that!ismissing(x)
implies thatx::Int
.The text was updated successfully, but these errors were encountered: