eclipse-zenoh / zenoh-pico

Eclipse zenoh for pico devices
Other
107 stars 67 forks source link

[Bug] To high cpu load #594

Open alexzeit opened 1 month ago

alexzeit commented 1 month ago

Describe the bug

The performance of zenoh-pico in zephyr is not OK. It makes very high cpu load. I have tested with one publisher and one subscriber in separate threads.

zenoh-pico publisher: dt 1ms payload 28 bytes python publischer dt: 2ms payload 26 bytes

Here the Thread analyze:

0x24002288 zenoh-pico publisher thread 0x24003910 zenoh-pico subscriber thread

Thread analyze: 0x240021b0 : STACK: unused 1740 usage 1332 / 3072 (43 %); CPU: 0 % : Total CPU cycles used: 3491514 0x24002288 : STACK: unused 2364 usage 1732 / 4096 (42 %); CPU: 24 % : Total CPU cycles used: 10597211451 0x24003a20 : STACK: unused 1004 usage 1044 / 2048 (50 %); CPU: 0 % : Total CPU cycles used: 2320557 0x24003910 : STACK: unused 336 usage 1712 / 2048 (83 %); CPU: 48 % : Total CPU cycles used: 20912280179 thread_analyzer : STACK: unused 560 usage 464 / 1024 (45 %); CPU: 0 % : Total CPU cycles used: 6940094 net_socket_service : STACK: unused 776 usage 440 / 1216 (36 %); CPU: 0 % : Total CPU cycles used: 6666 rx_q[0] : STACK: unused 1088 usage 448 / 1536 (29 %); CPU: 5 % : Total CPU cycles used: 2487365484 stm_eth : STACK: unused 1232 usage 304 / 1536 (19 %); CPU: 2 % : Total CPU cycles used: 1169114540 net_mgmt : STACK: unused 272 usage 496 / 768 (64 %); CPU: 0 % : Total CPU cycles used: 47966 tcp_work : STACK: unused 880 usage 144 / 1024 (14 %); CPU: 0 % : Total CPU cycles used: 1344 shell_uart : STACK: unused 1448 usage 600 / 2048 (29 %); CPU: 0 % : Total CPU cycles used: 62139925 sysworkq : STACK: unused 324 usage 700 / 1024 (68 %); CPU: 0 % : Total CPU cycles used: 3957396 logging : STACK: unused 492 usage 276 / 768 (35 %); CPU: 0 % : Total CPU cycles used: 1483785 idle : STACK: unused 272 usage 48 / 320 (15 %); CPU: 18 % : Total CPU cycles used: 8155587915 main : STACK: unused 444 usage 1604 / 2048 (78 %); CPU: 0 % : Total CPU cycles used: 6389063 ISR0 : STACK: unused 1840 usage 208 / 2048 (10 %)

To reproduce

  1. configure zenoh-pico peer mode and publisher interval=1ms
  2. activate zephyr thread analyze: CONFIG_THREAD_ANALYZER=y CONFIG_THREAD_ANALYZER_AUTO=y CONFIG_THREAD_ANALYZER_USE_PRINTK=y CONFIG_THREAD_ANALYZER_AUTO_INTERVAL=20 CONFIG_LOG_BUFFER_SIZE=4096
  3. flash and start zenoh-pico publisher and subscriber
  4. configure python publisher and subscriber peer mode and interval=2ms
  5. start python publisher and subscriber

System info

jean-roland commented 3 weeks ago

Hello @alexzeit, we intend to measure and improve performance and memory usage of zenoh-pico after the release 1.0 so we'll look into that in the near future but not now.