mfgarvin / DOC_Mapboard

3 stars 0 forks source link

High CPU load at idle #2

Closed mfgarvin closed 1 year ago

mfgarvin commented 2 years ago

Frequently, two threads take 100% cpu time each, even at idle. Likely due to improper / inefficient threading configuration.

tcgarvin commented 2 years ago

I'm not 100% sure I'm reading this for loop correctly, but you might want to make this sleep statement happen every iteration. Otherwise this check will just run as fast as it can

mfgarvin commented 2 years ago

Good catch - that's one thread fixed

mfgarvin commented 2 years ago

Here's the other problematic bit. Not sure why, but something about these calculations is pretty cpu intensive. https://github.com/mfgarvin/DOC_Mapboard/blob/6dbc3f77fe96b524d9aded373e7a27580ea0be55/main.py#L357-L362 https://github.com/mfgarvin/DOC_Mapboard/blob/6dbc3f77fe96b524d9aded373e7a27580ea0be55/main.py#L375-L383

mfgarvin commented 1 year ago

Pretty sure the issue at hand is that the math of the breathingEffect function just uses a lot of CPU cycles, and each LED thread that uses it starts its own instance, which quickly adds up. Not really worth fixing.