Page 1 of 1

CPU usage when logging from Raspberry Pi

Posted: Mon Aug 02, 2021 7:56 am
by huizerd
Hi all,

When running the basic asynchronous logging example (https://github.com/bitcraze/crazyflie-l ... asiclog.py) on a Raspberry Pi 4, we found that it used up more than 30% of the CPU, even with the logging frequency set to 1 Hz. Is this known, or might there be something obvious we're doing wrong? The amount of CPU usage seems excessive for such a seemingly simple task. Thanks!

Jesse

Re: CPU usage when logging from Raspberry Pi

Posted: Tue Aug 03, 2021 9:06 am
by arnaud
Hi Jesse,

It unfortunately sounds correct. The main problem is that the radio USB communication happens at pretty low level: the python lib has to send and receive every single packets and since the Crazyflie downlink is implemented using ack packets, the lib has to send packet very often to implement the downlink.

This means that starting a connection generates at least 800 usb transfer per seconds and this takes some CPU. I have been planning an nRF52840 based Crazyradio 2 that will be handling that in the firmware and so will relieve the client from actively polling and so make the connection much more efficient. I hope I will be able to start working on that in Q4.

In the meantime I am afraid there is not much to do. On the raspi4 you can maybe try the USB2 and USB3 ports to see if it makes a difference: the USB3 ports are over PCI-E while the USB2 ports are directly implemented in the SoC. Maybe one sort will be more efficient than the other.

If you do not need much bandwidth, you can limit the polling rate in the lib by setting "waitTime" to a higher number than 0 (in seconds): https://github.com/bitcraze/crazyflie-l ... #L637-L642.

/Arnaud

Re: CPU usage when logging from Raspberry Pi

Posted: Tue Aug 03, 2021 12:01 pm
by huizerd
Hi Arnaud,

Alright, that's good to know. Thanks for the suggestions, we'll try them out. Looking forward to the new radio ;)

Jesse