Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
fixes #199 #200
fixes #199 #200
Changes from 3 commits
d2a7dc5
e482f7e
019f1a7
cd9c081
2d22cfb
651fcd7
883a3f0
f443a2b
4088745
5a07645
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Why an
unordered_set
? Why not a vector for instance? Was this experimentally shown to be faster?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.
I chose
unordered_set
to avoid duplicates. When clearing the world points, we don't care about the Z coordinate. If we clear world point (1, 2, 3) and (1, 2, 4), they're both gonna be in the same costmap cell, so there is no need to store and iterate through it twice.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.
OK, that seems reasonable. I'd ask though if you'd test both and use which ever is practically faster. The STL Vector implementation is very cache friendly, so even areas where you wouldn't think it would be faster to use (because of duplications for instance), it ends up being faster due to continuous memory buffers (I ran into that alot while developing this: what you "think" should be faster based on theory and what is actually faster are not always intuitive). I don't know if it would be faster or not, so please test and let me know.
You can create an update timer pretty easily with chrono
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.
You're right,
vector
is a lot faster thanunordered_set
when iterating through its contents, even though its size is a lot bigger due to duplicated elements. However,vector
is only faster if we don't do anything while iterating. Since we need to touch every element, thenunordered_set
becomes the faster alternative since it has fewer elements - meaning less calls totouch
.I recorded two small clips where you can see the time it takes for both cases, when decay time is set to 0 (i.e. instant clearing):
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.
What was the looping testing? Just the loop without
touch
(so emptyfor
?)Keep in mind its not just access for iteration, its also about insertion time since vector insertion would probably be faster due to no hash table lookups for existing keys. You should try to measure the full update and take some metrics based on that since the insertions are pretty built into the clearing function. I agree its looking good for the
unordered_set
but just want to validate. I did alot of testing on datastructures to make STVL real-time so I want to ensure this doesn't have an undo impact on the overall performance.So tl;dr
So we can answer the questions:
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.
I averaged 450 update cycles with the following scenario (decay time set to 0):
The start time was set right before defining the
cleared_cells
variable:spatio_temporal_voxel_layer/src/spatio_temporal_voxel_layer.cpp
Line 727 in 651fcd7
and end time at the very bottom of the function, right before
return
.If I set the start time at the top of the function the execution times were very inconsistent, I'm guessing due to the calls to
GetObservations
methods. I don't think my changes should affect the performance before we clear anyway, so I set the start time after the observations are obtained, in order to get more consistent times.Results (units in microseconds):
So
unordered_set
andvector
have basically the same performance, which was ~0.5ms worse than the baseline.