-
-
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
Making sum(skipmissing(x)) faster #27679
Comments
After some experimentation, it turns out The more general problem is that we cannot use |
Actually it doesn't seem possible to implement an efficient
So I had to implement a full |
sum(skipmissing(x))
is reasonably fast, but since #27651 a naive implementation ofsum
is even faster (up to 5×). This is particularly clear when the input array does contain missing values, probably because the naive sum uses masked SIMD instructions whileskipmissing
relies on branching (and the presence of missing values kills prediction).I haven't investigated this deeply, but IIUC
sum(skipmissing(x))
dispatches tomapfoldl
, which uses the iteration protocol to go over the input. This means we lose the benefit of@inbounds
and of@simd
. Maybe something like #27384 would help with@inbounds
at least?The text was updated successfully, but these errors were encountered: