Skip to content
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

Reduce preempt stop time in stages #598

Merged
merged 5 commits into from
Jul 19, 2024

Conversation

captain-yoshi
Copy link
Contributor

This is a follow up to #597. To reduce time when preempting a task for each stages.

Stages now checks if there has been a preempt request before doing the compute() method. Let me know if there would be a cleaner way to achieve this.

This does not preempt a stage that has already began the compute() method.

@codecov-commenter
Copy link

codecov-commenter commented Jul 17, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 78.94737% with 4 lines in your changes missing coverage. Please review.

Project coverage is 55.70%. Comparing base (6b0f2c8) to head (f3a1abe).
Report is 36 commits behind head on master.

Files Patch % Lines
core/src/task.cpp 66.67% 2 Missing ⚠️
core/include/moveit/task_constructor/stage_p.h 85.72% 1 Missing ⚠️
core/src/stage.cpp 50.00% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #598      +/-   ##
==========================================
- Coverage   58.82%   55.70%   -3.12%     
==========================================
  Files          91      132      +41     
  Lines        8623    10796    +2173     
  Branches        0      901     +901     
==========================================
+ Hits         5072     6013     +941     
- Misses       3551     4736    +1185     
- Partials        0       47      +47     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@rhaschke rhaschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A std::function object is somewhat costly. What about using a direct pointer to the tasks's preempt_requested_ flag? Initially, that pointer will be NULL and the task's init function sets it.

core/include/moveit/task_constructor/stage_p.h Outdated Show resolved Hide resolved
core/test/test_container.cpp Outdated Show resolved Hide resolved
core/test/test_container.cpp Outdated Show resolved Hide resolved
@rhaschke
Copy link
Contributor

I merged #597. Please rebase.

Checked at the start of the StagePrivate::runCompute(). A callback must
be issued, otherwise the stage/s cannot be preempted.
Forward Task::isPreempted() to all stages.
Copy link
Contributor

@rhaschke rhaschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for incorporating my suggestions. I have a few more.

core/test/test_container.cpp Outdated Show resolved Hide resolved
core/test/test_container.cpp Outdated Show resolved Hide resolved
core/test/test_container.cpp Outdated Show resolved Hide resolved
core/include/moveit/task_constructor/stage_p.h Outdated Show resolved Hide resolved
core/include/moveit/task_constructor/stage_p.h Outdated Show resolved Hide resolved
core/include/moveit/task_constructor/stage_p.h Outdated Show resolved Hide resolved
core/include/moveit/task_constructor/task.h Outdated Show resolved Hide resolved
@captain-yoshi
Copy link
Contributor Author

captain-yoshi commented Jul 18, 2024

Second wave of suggestions done.

I think we should add a meaningful error message when throwing the PreemptStageException (if it throws somewhere e.g. in test units). Because I got something like this and did not know what it was at first glance:

[ RUN      ] CostTerm.SolutionConnected
unknown file: Failure
C++ exception with description "" thrown in the test body.
[  FAILED  ] CostTerm.SolutionConnected (0 ms)
[ RUN      ] CostTerm.SetLambdaCostTerm
unknown file: Failure
C++ exception with description "" thrown in the test body.

@rhaschke
Copy link
Contributor

I think we should add a meaningful error message when throwing the PreemptStageException

Isn't the exception always caught in Task::compute()?

@captain-yoshi
Copy link
Contributor Author

Yes when using the Task API. But when running some tests with only containers/mockups it may throw and no message is displayed.

[ RUN      ] GeneratorMockup.delayed
unknown file: Failure
C++ exception with description "std::exception" thrown in the test body.
[  FAILED  ] GeneratorMockup.delayed (0 ms)

[  FAILED  ] 1 test, listed below:
[  FAILED  ] GeneratorMockup.delayed

...

[  FAILED  ] 9 tests, listed below:
[  FAILED  ] CostTerm.SolutionConnected
[  FAILED  ] CostTerm.SetLambdaCostTerm
[  FAILED  ] CostTerm.CostOverwrite
[  FAILED  ] CostTerm.StageTypes
[  FAILED  ] CostTerm.PassThroughUsesCost
[  FAILED  ] CostTerm.PassThroughOverwritesCost
[  FAILED  ] CostTerm.PassThroughCanModifyCost
[  FAILED  ] CostTerm.CompositeSolutions
[  FAILED  ] CostTerm.CompositeSolutionsContainerCost

@rhaschke
Copy link
Contributor

But when running some tests with only containers/mockups it may throw and no message is displayed.

I cannot reproduce these results. As far as I can see, those tests don't call preempt().

@captain-yoshi
Copy link
Contributor Author

Yup. It happened to me because the preempted() function had bad logic initially.

bool preempted() const { return !preempt_requested_ || *preempt_requested_); }

@rhaschke rhaschke merged commit fdc06c3 into moveit:master Jul 19, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants