-
Notifications
You must be signed in to change notification settings - Fork 327
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
significantly improve execution time and cpu use of "sample" for large trajectories #474
Conversation
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.
Looking good.
On a side note. Do you have any idea how to test this on a CI? We could define specific range trajectory should be exectued or something.
joint_trajectory_controller/include/joint_trajectory_controller/trajectory.hpp
Outdated
Show resolved
Hide resolved
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #474 +/- ##
===========================================
- Coverage 44.88% 32.48% -12.41%
===========================================
Files 40 7 -33
Lines 3636 665 -2971
Branches 1716 357 -1359
===========================================
- Hits 1632 216 -1416
+ Misses 832 157 -675
+ Partials 1172 292 -880
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
The sample()
method has a pretty large docstring documenting behaviour and parameters. Could you please add this extra feature in there with sufficient documentation about the expected behaviour?
Indeed @destogl , this should be also tested not only for speed but some simple unit test setup ensuring that the scenarios we call |
I'd be happy to try my hand writing tests to verify performance, as well as verifying existing tests work - however there is a looming deadline at work on December 15th so I likely won't get around to it until after that date. Thanks for both of your time, |
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.
We need to think this better through and think about other possible optimizations.
This pull request is in conflict. Could you fix it @jbeck28? |
Hello, Sorry for letting this rot for a year... also for my confusion. I don't believe that this PR should change the signature for the sample method. The only way I could see the behavior of "sample" changing would be if one were to call sample at time "t", and then subsequently called "sample" at time T < t. It looks like the existing unit tests passed, however. Some guidance on what folks would like changed or improved would be much appreciated. Thanks, |
Can I ask what you think might be wrong with this change? From my experience with this, if you have very large trajectories, this is much faster because otherwise the sample method always starts back at zero. We would like to use binaries, but this one small change stops us from being able to do so. |
It seems that something happened with the latest merge, have you worked on humble but merged now the master branch? The diff view shows >200 changed files. I suggest cherry-picking your relevant commits onto a new branch from master, and force push on your jbeck28:humble branch to keep the discussion from above in this PR. (Or you make a new one, and link this PR in the description). |
Personally I'd be happy to merge this as long as we have tests that specifically address this functionality. |
@jodle001 @jbeck28 the remaining ask is very simple: Unit tests not only ensure your code keeps working in the long run but also serves as proof of intent on what function you imagined that piece of code to fulfil.
But again, you probably know better since it's your changes ;) You can't reliably measure performance with |
This pull request is in conflict. Could you fix it @jbeck28? |
Hi Bence, thanks for the clarification. I understand the value of unit testing but lack much experience in creating them, so my apologies if this comes across as argumentative (or stupid). I think the confusion I'm having here is that this change doesn't add functionality. The only salient change this makes is reducing the time required to execute "sample" with large trajectories - and like you pointed out that's not entirely possible to test quantitatively. The latest commit I made "implemented" a test which was supposed to verify the index increments properly, but after pushing the commit I realized this is exactly the test cases already implemented starting here. I guess I feel like if the previous tests for trajectory are still passing, then this doesn't break any existing functionality. That said, the one thing this does change is it demands that consecutive calls to "sample" must be done at monotonically increasing times. I don't think that it should ever happen where the nth call to sample is at time t and the n+1'th call is at time T < t. I'll be very curious to hear your thoughts on this, and I can easily write a test to demonstrate the situation I've described if needed. Thanks, |
Superseded by #1297 |
I noticed for trajectories which contain ~25k waypoints that CPU usage would grow continuously over the course of the trajectory's execution. I narrowed this down to "sample" always starting from the beginning of the trajectory. This small change fixed the issue.