Parrot-Developers/olympe

CPU load increases over time to 100%

Closed this issue · 2 comments

iaamp commented

The issue:
CPU load of the Python process increases over time until it reaches 100%. This in turn slows down everything in the Python process, and if using threads, these can get starved due to _thread.lock times of a couple seconds.

How to reproduce:
pair Parrot Anafi with SkyController
connect SkyController to computer via USB
use an example file, i used olympe/doc/example/listener.py
modify the file in following way:

import time
...
# using Parrot Anafi with SkyController
DRONE_IP = "192.168.53.1"
...
# remove all listeners
# remove all asserts and calls that would move the drone
...
drone.connect()
while True:
    time.sleep(1)
...

Observation:
Over time, CPU load increases until it reaches 100% (of one core/thread, not whole system). Once there, obviously load cannot further increase, due to Pythons GIL. It starts out at my machine (Intel NUC i7 with Ubuntu 20.04) at about 15-20% CPU usage (of one core/thread, not total system). The total time until 100% is reached seems to depend on the number of additional calls, e.g. listeners. On my machine, it takes up to 10 minutes in this example, and about 3-4 minutes with my my application that uses Olympe SDK.

Expectation:
Python processes using Olympe SDK run stable at constant CPU load forever. From my perspective, there is no reason why anything should accumulate in in the drone object that would lead to this behavior.

Already tested
Removing the call to drone.connect() fixes the issue
Removing the listeners seemed to slow down the accumulation of CPU load, but i didn't profile it

System Info
Intel NUC i7
Ubuntu 20.04
Linux 5.13.0-rt1 (Note: observed same behaviour before on non-RT kernel)
Python 3.8.10
virtualenv 20.16.7
Olympe 7.4.2 running in an virtualenv (Note: i observed the bug before in 7.2.x, but back then thought it was an issue with my own code)

This should be fixed in the 7.5.0-rc1 release.

This should now be fixed in the 7.5.0 final release.