Iterate over IntraProcessBuffer instead of creating a vector - #3272
Closed
thomasmoore-torc wants to merge 2 commits into
Closed
thomasmoore-torc wants to merge 2 commits into
thomasmoore-torc wants to merge 2 commits into
Conversation
(cherry picked from commit 1b6ee8a5a4fbc447c97c55007b7eb2049cb1be47) Signed-off-by: Thomas Moore <thomas.moore@torc.ai>
(cherry picked from commit 13aae0cbbdb0910213318305c0df176eefe248d6) Signed-off-by: Thomas Moore <thomas.moore@torc.ai>
Collaborator
|
This AI generated PR description is pretty muss useless. |
Author
|
The goal is to eliminate unnecessary memory allocations. This is achieved by iterating over the |
Collaborator
|
Did you somehow verify that there is a real performance enhancement ? |
thomasmoore-torc
force-pushed
the
intra-process-reduce-copies
branch
from
September 15, 2026 14:19
a70b7ba to
be68676
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
rclcpp: Reduce unnecessary copies/allocations in intra-process publish
Branch:
intra-process-reduce-copies(this repo:ros2/rclcpp)Related PR: #3271 — "Populate message info for intra-process messages" (
intra-process-message-info). See Landing order below — no functional dependency, but the two touch overlapping code.Summary
Two avoidable allocation/copy hot spots in the intra-process publish path:
IntraProcessManagerrecomputes and concatenates the take-ownership subscription ID lists (inter-process-need + intra-process-need) into a freshstd::vectoron every single publish call, even though the set of registered subscriptions only changes onadd_subscription/remove_subscription.std::vectorcopy of the ring buffer's contents first, then iterates it, rather than visiting the buffer's storage directly.Changes
Pre-compute concatenated take ownership subscriptions— caches the merged take-ownership subscription id list, invalidating/recomputing it only when subscriptions are added or removed, instead of rebuilding it on every publish.Iterate over IntraProcessBuffer instead of creating a vector— addsfor_each_shared/for_each_uniquevisitor-style iteration overIntraProcessBuffer's ring-buffer storage (covering all shared/unique storage × shared/unique request combinations, including the move-only unique-ptr case), and switches vector-materializing call sites to use it instead.Compatibility
Internal to
rclcpp's intra-process implementation (rclcpp::experimental::*); no public API or observable behavior changes — this is a pure performance/allocation-reduction change.Testing
Built and tested against
rollingin aros:rolling-ros-basecontainer viacolcon build/colcon testforrclcpp(3091 tests, 0 failures), plusuncrustify/cpplintlint targets. All green.Landing order
intra-process-message-info(opened separately) touches the same files (intra_process_buffer.hpp,intra_process_manager.hpp, and both intra-process test files) as part of an unrelated feature adding message-info propagation. The two branches are independently buildable and testable, but not free to merge in either order without a rebase — real textual conflicts exist between them (confirmed via a trial merge). No functional dependency either way; whichever of the two merges second will need to reconcile against the other.🤖 Generated with Claude Code