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

Reduce redux saveState overhead #283

Merged
merged 3 commits into from
Jul 22, 2023
Merged

Conversation

mayfield
Copy link
Contributor

I noticed my CPU was quite high when downloading big streams and most of the CPU was being spent doing browser.storage.local.set(...) for saving the state. This state only appears to be needed when the background page is reloaded (which will never happen if the a content-script is active.

Buffering the save by 200ms reduces JS overhead by about ~40% (not including native methods overhead) and total CPU usage on my system (circa 2022 AMD 16 core) is reduced by ~28%.

Attaching 10s profile captures before(unbuffered) and after (buffered):

hls-perf-traces.tar.gz

mayfield and others added 3 commits July 10, 2023 16:05
I noticed my CPU was quite high when downloading big streams and most of
the CPU was being spent doing browser.storage.local.set(...) for saving
the state.  This state only appears to be needed when the background
page is reloaded (which will never happen if the a content-script is
active.

Buffering the save by 200ms reduces JS overhead by about ~40% (not
including native methods overhead) and total CPU usage on my system
(circa 2022 AMD 16 core) is reduced by ~28%.
@puemos
Copy link
Owner

puemos commented Jul 12, 2023

Awesome work! I decided to use a "throttle" function. Wdyt?

@mayfield
Copy link
Contributor Author

I didn't bench 100ms vs 200ms but I'm sure it's fine.

LGTM

@puemos puemos merged commit 68ce610 into puemos:master Jul 22, 2023
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

Successfully merging this pull request may close these issues.

2 participants