-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Improve performance of WebSocketReader #8736
Conversation
this is a paired down version of #8735 to better optimize for both the non-continuation and continuation case
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #8736 +/- ##
==========================================
- Coverage 98.14% 98.13% -0.01%
==========================================
Files 107 107
Lines 34062 34065 +3
Branches 4029 4030 +1
==========================================
+ Hits 33430 33431 +1
- Misses 456 457 +1
- Partials 176 177 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Backport to 3.10: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply 1b88af2 on top of patchback/backports/3.10/1b88af2c3f5e5f992d0015f90927fd9c3e00bef0/pr-8736 Backporting merged PR #8736 into master
🤖 @patchback |
Backport to 3.11: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply 1b88af2 on top of patchback/backports/3.11/1b88af2c3f5e5f992d0015f90927fd9c3e00bef0/pr-8736 Backporting merged PR #8736 into master
🤖 @patchback |
(cherry picked from commit 1b88af2)
(cherry picked from commit 1b88af2)
Optimization
bytearray.extend
with+
and+=
https://stackoverflow.com/questions/40004517/why-does-bytearray-obj-extendbytes-differ-from-bytearray-obj-bytesself._partial
is never needed for the non-continuation case and we can avoid having toextend
andclear
it for this case, which is the common case for many use cases.This is a paired down version of #8735 to better optimize for both the non-continuation and continuation case
Testing
feed_data
on a live HA instance. Testing was done on an Odroid N2+ SBC. Performance numbers will vary based on CPU and memory performance.~6% faster for the continuation case (real world use case is listening to a unifi instance)
~34% faster for the non-continuation case (real world use case is reading Bluetooth data from a shelly device, web based terminal shows a similar improvement)
Improvement percentages will be less impressive on systems with faster CPU/memory performance.
related discussion #8258
benchmark for non-continuation case
profiler