-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Improve VoxelGrid
filter runtime by ~20% by using spread sort
#3853
Improve VoxelGrid
filter runtime by ~20% by using spread sort
#3853
Conversation
VoxelGrid spends a lot of time sorting. Radix sort implemted in boost seems to be faster than std::sort
As long as you're sorting integers it should indeed always be faster than
|
@Morwenn . thanks for adding some context. You may find a reproducible benchmark here: |
How about making the sort algorithm a policy or input of the filter? Since other places in PCL could have bad defaults too, and this can be a start in giving the users more freedom. PCL should still provide good defaults (ala this PR), but we can let the users choose an algorithm that works best for them. |
Honestly, if no one cared to optimize this so far, no one will care to customize it in the future. The general user doesn't need to know that VoxelGrid filter uses a sorting algorithm and even less to know which is the best sorting algorithm for his/her use case. And if std::sort is always slower, why should I have the "freedom" to select it? |
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.
Apart from small inline remarks, I'm in favor of merging this.
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!
VoxelGrid
filter runtime by ~20% by using spread sort
@facontidavide I had the chance to test the efficacy of your PR (I did need to backport it to PCL 1.8.1 and build from source) and my testing with real data from Velodyne pointclouds gave 23-24% speed improvement, with 0.8% of the computations taking equal or longer than with the previous implementation (could just be my CPU having hickups). I computed it by doing doing an average over comparing pointclouds processed one-to-one and also over total times running some relatively big custom datasets. |
Good to know the actual numbers 😊 |
VoxelGrid spends a lot of time sorting.
Spread sort implemented in boost seems to be faster than std::sort.
I get an average speed improvement of 20%, but it would be nice if anyone can reproduce this.