Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High CPU load at idle #2

Closed
mfgarvin opened this issue May 25, 2022 · 4 comments
Closed

High CPU load at idle #2

mfgarvin opened this issue May 25, 2022 · 4 comments

Comments

@mfgarvin
Copy link
Owner

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

@tcgarvin
Copy link

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
Copy link
Owner Author

Good catch - that's one thread fixed

@mfgarvin
Copy link
Owner Author

Here's the other problematic bit. Not sure why, but something about these calculations is pretty cpu intensive.

DOC_Mapboard/main.py

Lines 357 to 362 in 6dbc3f7

elif (style == "pulse"): # Sets an LED to pulse
time.sleep(0.01)
cos = breathingEffect(randomint)
livecolor = (int(color[0] * cos), int(color[1] * cos), int(color[2] * cos))
pixels[led] = livecolor
pass

DOC_Mapboard/main.py

Lines 375 to 383 in 6dbc3f7

def breathingEffect(adjustment): # Background code called by "pulse" above, supports the fading method.
period = 20
omega = 2 * math.pi / period
phase = 0
offset = 0.5
amplitude = 0.5
timer = time.time() + adjustment
value = offset + amplitude * (math.cos((omega * timer) + phase))
return(value)

@mfgarvin
Copy link
Owner Author

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.

@mfgarvin mfgarvin closed this as not planned Won't fix, can't repro, duplicate, stale Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants