-
Notifications
You must be signed in to change notification settings - Fork 260
Description
Bug report
Required Info:
-
Operating System: Ubuntu 22.04
-
Installation type: Binaries
-
Version or commit hash: Iron
-
DDS implementation: eProsima’s Fast DDS (the default)
-
Client library (if applicable): rclpy
-
CPU info (if needed):
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 39 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 12
On-line CPU(s) list: 0-11
Vendor ID: GenuineIntel
Model name: 13th Gen Intel(R) Core(TM) i7-1355U
CPU family: 6
Model: 186
Thread(s) per core: 2
Core(s) per socket: 10
Socket(s): 1
Stepping: 3
CPU max MHz: 5000.0000
CPU min MHz: 400.0000
BogoMIPS: 5222.40
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflus
h dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constan
t_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aper
fmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse
3 sdbg fma cx16 xtpr pdcm sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer
aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb ssbd ibrs
ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbas
e tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb
intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves avx_vnni dtherm ida arat pln pt
s hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req hfi umip pku ospke waitpkg
gfni vaes vpclmulqdq rdpid movdiri movdir64b fsrm md_clear serialize arch_lbr
ibt flush_l1d arch_capabilities
Virtualization features:
Virtualization: VT-x
Caches (sum of all):
L1d: 352 KiB (10 instances)
L1i: 576 KiB (10 instances)
L2: 6.5 MiB (4 instances)
L3: 12 MiB (1 instance)
NUMA:
NUMA node(s): 1
NUMA node0 CPU(s): 0-11
Vulnerabilities:
Gather data sampling: Not affected
Itlb multihit: Not affected
L1tf: Not affected
Mds: Not affected
Meltdown: Not affected
Mmio stale data: Not affected
Retbleed: Not affected
Spec rstack overflow: Not affected
Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl
Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Spectre v2: Mitigation; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW seque
nce
Srbds: Not affected
Tsx async abort: Not affectedSteps to reproduce issue
My publisher:
import rclpy
from rclpy.node import Node
from std_msgs.msg import String
import time
class MyPublisher(Node):
def __init__(self):
super().__init__('my_publisher')
self.publisher_ = self.create_publisher(String, 'my_topic', 10 )
timer_period = 1 / 500
self.timer = self.create_timer(timer_period, self.timer_callback)
def timer_callback(self):
msg = String()
msg.data = 'Hello, ROS2! '
self.publisher_.publish(msg)my subscriber:
import rclpy
from rclpy.node import Node
from std_msgs.msg import String
class MySubscriber(Node):
def __init__(self):
super().__init__('my_subscriber')
self.subscription = self.create_subscription(
String,
'my_topic',
self.listener_callback,
10)
self.subscription # prevent unused variable warning
def listener_callback(self, msg):
passAnd my main function:
import rclpy
from my_multithreaded_package.publisher import MyPublisher
from my_multithreaded_package.subscriber import MySubscriber
import time
def main(args=None):
rclpy.init(args=args)
publisher = MyPublisher()
subscriber = MySubscriber()
executor = rclpy.executors.MultiThreadedExecutor(4)
executor.add_node(publisher)
executor.add_node(subscriber)
executor.spin()
# Shutdown the ROS client library
rclpy.shutdown()
if __name__ == '__main__':
main()Expected behavior (which is what I get when using the SingleThreadedExecutor)
ros2 topic hz /my_topic
average rate: 499.945
min: 0.002s max: 0.002s std dev: 0.00007s window: 501
average rate: 499.965
min: 0.001s max: 0.002s std dev: 0.00008s window: 1001
average rate: 499.995
min: 0.001s max: 0.003s std dev: 0.00009s window: 1502
average rate: 499.981
min: 0.001s max: 0.003s std dev: 0.00009s window: 2002
average rate: 499.978
min: 0.001s max: 0.003s std dev: 0.00009s window: 2502
average rate: 500.004
min: 0.001s max: 0.003s std dev: 0.00009s window: 3003
average rate: 499.989
min: 0.001s max: 0.003s std dev: 0.00010s window: 3503Actual behavior
ros2 topic hz /my_topic
average rate: 25.933
min: 0.002s max: 0.919s std dev: 0.16741s window: 29
average rate: 14.580
min: 0.000s max: 0.937s std dev: 0.21933s window: 41
average rate: 13.928
min: 0.000s max: 0.937s std dev: 0.21447s window: 62
average rate: 12.983
min: 0.000s max: 0.937s std dev: 0.22058s window: 81
average rate: 10.575
min: 0.000s max: 0.937s std dev: 0.24748s window: 85
average rate: 9.774
min: 0.000s max: 0.937s std dev: 0.25675s window: 89
average rate: 9.845
min: 0.000s max: 0.937s std dev: 0.25056s window: 102
average rate: 9.399Additional information
So similar issues have been brought up with rclcpp, but I have not seen any comments made about rclpy. I found an issue here:ros2/rclcpp#1487, with other people also reporting something like: ros2/rclcpp#1618 and the fix is ros2/rclcpp#1516 and then ros2/rclcpp#1692.
Aside from the timer callback hanging (I assume it to be with after following some tic toc), my CPU load becomes really high using the MultiThreadedExecutor, while the SingleThreadedExecutor does not cause any noticeable CPU load. I have also tried using both the MutuallyExclusiveCallbackGroup and ReentrantCallbackGroup with no change in behaviour.
I am not sure if my QOS settings are the problem, or this is an issue intrinsic to python (because of GIL or etc.) but either a more suitable example for how to use the MultiThreadedExecutor could be provided (if my usage is wrong), or the ROS wiki pages should reflect that this significant problem exists (if no fix is possible).
Thank you for helping!