CarletonURocketry / ground-station

The ground station software used to interface with the ground station LoRa board and distribute signals from the rocket across websocket connections.
https://carletonurocketry.github.io/ground-station/
MIT License
6 stars 5 forks source link

Fix spin loops #68

Closed AngelOnFira closed 4 months ago

AngelOnFira commented 4 months ago

Closes #67.

This fixes several areas in the code that were set up as "spin loops"; loops that would run as fast as the CPU they're on would let them. Instead, 2/3 fixes make use of Python's Queue.get() to block a thread until there is a new item in the queue to process.

The third "solution" is a hack that doesn't fully solve the problem, but mitigates the effect for now. A larger refactor will be required to properly improve this hotspot.

Before this PR, 3 CPUs would be pinned while running the backend (see image below). Now, running the backend shouldn't be noticeable (assuming it's not hard for the Pi to run with the current sleep rate).

image

linguini1 commented 4 months ago

Also, I have invited you to join the CarletonURocketry org so that you can make branches instead of forking.