-
Notifications
You must be signed in to change notification settings - Fork 303
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
fix: Fixes issue #2579 #2580
fix: Fixes issue #2579 #2580
Conversation
### Summary of the CPU Issue and Solution **Problem:** The implementation with **parallel loading** of Alexa components caused high CPU usage. Multiple components were loaded simultaneously, which overwhelmed the system due to the concurrent resource-heavy operations. **Solution:** 1. **Serial Loading:** I addressed the CPU problem by **serializing** the loading process. This means components are now loaded **one after the other** instead of all at once, reducing the CPU load. 2. **Condition with `entry_setup`:** I reintroduced the check for `if not entry_setup`. This ensures that we only initialize components if they are not already set up, preventing redundant operations. For components already initialized, the same `async_forward_entry_setup` method is called to reload them. **Outcome:** By loading components sequentially and ensuring that unnecessary setups are skipped, we significantly reduce the CPU load while maintaining efficient processing of new Alexa clients.
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line 1541 needs a ) removed from the end to fix a syntax error
Fix syntax error line 1541: unmatched ')' Co-authored-by: Andy Barratt <[email protected]>
for more information, see https://pre-commit.ci
Line 949 s/b @_catch_login_errors
Line 1452: revert async_unload_entry parameters
Please note, while I'm not opposed to what looks like ChatGPT changes, given the recent issue with #2579, I'm going to require someone actually test it before merging. That said, I want to thank you for being willing to do PRs. |
@jleinenbach Are you aware of PR #2589 to address memory exhaustion/infinite loop? |
@alandtse As you're no doubt aware, I implemented @jleinenbach's original code and then amended the PR with 3 edits to address issues I encountered with it. That said, I'm running the resulting |
The problem as described by this PR doesn't fit reports of #2579. It's not a problem of intense parallel activity. The symptom I've witnessed is sustained high CPU and increasing memory consumption until it runs out of memory and crashes. |
But the helper function has never been altered so I'm trying to understand what external change has caused the helper to now be in an infinite loop. If you don't know that's fine as processing a copy of the list when the original list is going to be changed by the process is the correct way otherwise you usually end up shooting yourself in the foot! |
It was altered. Foot shooting code was added in this release: 6f9a92d#diff-4e8bc1554181c711fd75da33fbb2b0e7a8a1abd5096c723a1d3baa9f3c10543c |
Went with #2589 |
Summary of the CPU Issue and Solution
Problem:
The implementation with parallel loading of Alexa components caused high CPU usage. Multiple components were loaded simultaneously, which overwhelmed the system due to the concurrent resource-heavy operations.
Solution:
Serial Loading: I addressed the CPU problem by serializing the loading process. This means components are now loaded one after the other instead of all at once, reducing the CPU load.
Condition with
entry_setup
: I reintroduced the check forif not entry_setup
. This ensures that we only initialize components if they are not already set up, preventing redundant operations. For components already initialized, the sameasync_forward_entry_setup
method is called to reload them.Outcome:
By loading components sequentially and ensuring that unnecessary setups are skipped, we significantly reduce the CPU load while maintaining efficient processing of new Alexa clients.