feat(tracing): emit the tracetools rmw_* tracepoints for ros2_tracing - #74
benaliabderrahmane wants to merge 2 commits into
Conversation
Add rmw_publisher_init, rmw_subscription_init, rmw_publish and rmw_take tracepoints, mirroring rmw_cyclonedds/rmw_fastrtps. ros2_tracing links a publish to its take across processes by rmw_publish.timestamp == rmw_take.source_timestamp; both sides pass WireHeader.source_timestamp_ns, so Trace Compass / CARET message-flow analysis now follows a message through UDS-connected nodes instead of stopping at the process boundary. Verified with an LTTng session over demo_nodes_cpp talker/listener under RMW_IMPLEMENTATION=rmw_unix_socket_cpp: 177/177 taken messages matched a publish event by timestamp; test_rmw_pub_sub and test_rmw_cross_process pass.
|
CI note: the lyrical failure is the distro image, not this PR.
Every test that links Evidence it predates this branch: a Also: GitHub only auto-links/auto-closes |
Description
Adds the four rmw-level tracepoints that
ros2_tracingdefines for an RMW —rmw_publisher_init,rmw_subscription_init,rmw_publish,rmw_take— mirroringrmw_cycloneddsandrmw_fastrtps. With them, the standard tracing stack (ros2 trace,tracetools_analysis, Trace Compass ROS 2 incubator, CARET) follows a message across processes on this RMW instead of stopping at the process boundary.How the cross-process link works.
ros2_tracingpairsrmw_publish.timestampin the publishing process withrmw_take.source_timestampin the receiving one by int64 equality. Both sides passWireHeader::source_timestamp_ns, the stamp already on the wire, so no wire-format change and no new state.What changed (20 lines, 4 files):
package.xml/CMakeLists.txt: depend on and linktracetools(PRIVATE; it is already a transitive dependency ofrcl, so nothing new gets installed).rmw_publisher.cpp:rmw_publisher_initat creation;rmw_publishinrmw_publishandrmw_publish_serialized_message, right after the header stamp is set.rmw_subscription.cpp:rmw_subscription_initat creation;rmw_takeon the successful-take path of all five take variants (rmw_take_sequencefires once per message). The analyses only consumetaken = 1events, so the empty-queue return does not emit.README.md: one row in the design table (separate commit, drop it if unwanted).On the sketch in #31. No
TRACETOOLS_ENABLEDguard is needed:TRACETOOLS_TRACEPOINTalready expands to nothing whentracetoolswas built with tracing disabled. There is no rmw-level wait tracepoint intracetools(waiting is covered by thercl/rclcppexecutor events), so nothing to emit there. Jazzy'stracetoolshas no request/response rmw tracepoints either, so a client → service hop across processes is still not linked by the analyses; that is an upstream gap, not something this RMW can fill.Fixes #31
Is this user-facing behavior change?
Additive.
ros2 tracesessions now recordrmw_*events from this RMW, and message-flow analyses work end to end. With no tracing session active, each call site costs one predicted-not-taken branch, the same as in the DDS RMWs.How was this tested?
Jazzy, host build (RelWithDebInfo).
test_rmw_pub_subandtest_rmw_cross_processpass.nm -Don the built.soshows the fourros_trace_rmw_*imports;lddshowslibtracetools.soandliblttng-ust.so.1.lttng enable-event -u 'ros2:*') overdemo_nodes_cpptalker + listener withRMW_IMPLEMENTATION=rmw_unix_socket_cpp, both nodes started after the session. Recorded 513rmw_publishand 187rmw_takeevents alongside the full rclcpp chain (callback_start/end,rclcpp_publish,rcl_take). All 177 distinctrmw_take.source_timestampvalues matched anrmw_publish.timestamp, i.e. every taken message links back to its publish:Did you use Generative AI?
Yes. Claude Code (Claude Fable 5.1) drafted the change, the LTTng verification scripts and this description.
Additional Information
Usage:
ros2 trace start <session>before launching the nodes (callback names and topic names come from init-time events), run the scenario,ros2 trace stop <session>, thenros2 trace-analysis process ~/.ros/tracing/<session>for a per-callback summary or open the trace in Trace Compass (ROS 2 Message Flow view) to follow one message across nodes.