-
Notifications
You must be signed in to change notification settings - Fork 850
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
Undo run end filter performance regression #6691
Conversation
… filter_run_end_array
I am running the benchmarks on this PR to verify. Thank you @delamarch3 |
I apologize for being denise @delamarch3 -- but I spent a while trying to find the benchmarks you are running and I couldn't figure out which they were. Is it the |
@alamb Sorry, I wrote a separate benchmark for this but I didn't commit it, it's not consistent with the results it returns on each run (the odd +/-5%) so I thought it needed work but there was enough of a difference to compare. I can add it into this PR though? |
I'll try to add one into |
Thank you -- if you could do so as a separate PR that would be most helpful (so it is easy to compare with these changes) 🙏 |
end -= difference; | ||
|
||
// Safety: we subtract the difference off `end` so we are always within bounds | ||
for pred in (start..end).map(|i| unsafe { filter_values.value_unchecked(i as usize) }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we could iterate on the filter_values
? E.g. let mut preds = filter_values.iter()
and calling preds.next()
in the loop. That way you can avoid using unsafe, while it might still generate fast code (?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'll try this out and post the results
I've run the for pred in filter_values
.iter()
.skip(start as usize)
.take((end - start) as usize)
{
count += R::Native::from(pred);
keep |= pred
}
for _ in start..end {
if let Some(pred) = preds.next() {
count += R::Native::from(pred);
keep |= pred
}
}
These two are similar but after running a few times the low selectivity benchmark seems slightly faster in this one end -= end.saturating_sub(filter_values.len() as u64);
for pred in (start..end).map(|i| unsafe { filter_values.value_unchecked(i as usize) }) {
count += R::Native::from(pred);
keep |= pred
}
|
Maybe you could try something like (two minor changes)?
I think you can leave out the |
I'm not sure calling I had to create a new variable with the count for assigning |
For me looks good - I feel somehow there probably should be more performance on the table. I believe the reason is I think it should be possible to improve |
Of course, you're right. |
Thanks @delamarch3 |
Which issue does this PR close?
Related to #6675
Rationale for this change
After running some benchmarks it turned out that the changes introduced in my previous PR were quite slow. This should bring it back closer to how it was before.
What changes are included in this PR?
I subtract the difference from
end
to keep it in bounds.Are there any user-facing changes?
No