Repository navigation
Take input buffers in list order instead of by timestamp - #350
Conversation
Samples that arrive within one clock tick get equal timestamps, and the strict comparison then returned the newest one. rcl_take swapped such samples, and KEEP_LAST could overwrite a newer sample than the oldest. The timestamp comes from rmw_uros_epoch_nanos(), so a time sync may also move it. Allocated items are inserted newest first, so the oldest buffer of an entity is its last match. Overwriting used to keep the buffer in place and break that order, so recycle it through the pool to move it to the head. timestamp remains for the lifespan check. Fixes micro-ROS#349 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Hao <hao3.li@tu-dortmund.de>
|
This pull request is merged. |
|
FYI, I used Claude Code to help with this, but I went through the change myself before opening the PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## rolling #350 +/- ##
===========================================
+ Coverage 54.93% 55.64% +0.71%
===========================================
Files 102 103 +1
Lines 5918 6027 +109
Branches 944 943 -1
===========================================
+ Hits 3251 3354 +103
- Misses 2330 2333 +3
- Partials 337 340 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
David-LP99
left a comment
There was a problem hiding this comment.
Thank your for raising the topic @Steve-Li-1998,
The proposed solution looks good, please check the requested changes.
Also, I would really appreciate if you could add the host tests you mentioned to the PR as unit tests.
Once this is approached I'll request backports to the other distros.
Returning the buffer to the pool and getting it back only served to move it to the head of the allocated list, which was hard to read. Add move_to_head to the memory pool and use it instead. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Hao <hao3.li@tu-dortmund.de>
Cover equal timestamps, overwrites, clock jumps, interleaved owners and a take between stores, plus move_to_head on a pool of its own. The tests use the buffer pool directly, so they need no Agent. Without the fix, six of the seven order tests fail. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Hao <hao3.li@tu-dortmund.de>
|
Thanks for the review, @David-LP99.
I could only build this locally against jazzy, so the rolling result depends on CI, which is waiting for approval to run. |
|
@mergify backport kilted jazzy humble |
✅ Backports have been createdDetails
|
|
Thanks for the review and the merge, @David-LP99. While tracking down this issue I also found a few defects in the XRCE Client and Agent, each with an issue and a fix:
Would you have time to look at them as well? |
Signed-off-by: Hao <hao3.li@tu-dortmund.de> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 122383e)
Signed-off-by: Hao <hao3.li@tu-dortmund.de> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 122383e)
Signed-off-by: Hao <hao3.li@tu-dortmund.de> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 122383e)
…) (#351) Signed-off-by: Hao <hao3.li@tu-dortmund.de> Co-authored-by: Hao <hao3.li@tu-dortmund.de> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…) (#352) Signed-off-by: Hao <hao3.li@tu-dortmund.de> Co-authored-by: Hao <hao3.li@tu-dortmund.de> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…) (#353) Signed-off-by: Hao <hao3.li@tu-dortmund.de> Co-authored-by: Hao <hao3.li@tu-dortmund.de> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Description
Fixes #349.
Input buffers of one entity are ordered by timestamp. Samples that arrive within one clock tick get equal timestamps, and the strict comparison then returns the newest one. This has two effects:
rcl_takereturns N+1 before N.Main changes
The allocated list is now the only source of order, with the newest item at the head.
rmw_uxrce_find_static_input_buffer_by_ownerreturns the last match instead of comparing timestamps.put_memoryandget_memory, which moves it to the head. It used to stay in place, so the newest sample could sit at the tail.timestampstays because the lifespan check needs it.This differs from the arrival counter I proposed in #349. It needs no new field and has the same effect. Changing
<to<=is not enough, because a buffer reused in place breaks the list order. With depth 2 and arrivals C, D, E sharing one timestamp,<=leaves[D, E]and takes E first.Testing
jazzyate64d79fwith this changerollingwith this changememory.cand the functions fromtypes.c, stored and taken the wayon_topicandrmw_takedo. It covers ties, overwrites, clock jumps, two interleaved owners and a take between stores. It uses subscription-style storage only and is not part of this PR.Backports
Could a maintainer please request backports to
kiltedandjazzythrough Mergify, and tohumbleif it applies?kiltedandjazzyhave the same comparison, and I have not checkedhumble.🤖 Generated with Claude Code