-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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(ui): perf improvements #5411
Conversation
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.
@psychedelicious @maryhipp - only thing blocking atm is lint checks are failing.
aa74411
to
b1370bd
Compare
I've also reviewed every single redux selector in the app and optimized all but a couple of them. The Our redux implementation is better now than it ever has been. Sweet! |
Pending resolution of reduxjs/reselect#635, we can patch `reselect` to use `lruMemoize` exclusively. Pin RTK and react-redux versions too just to be safe. This reduces the major GC events that were causing lag/stutters in the app, particularly in canvas and workflow editor.
This is a no-no, whoops!
Accidentally removed it last commit.
These were just using overly verbose syntax - like explicitly typing `state: RootState`, which is unnecessary.
Do not memoize unless absolutely necessary. Minor perf improvement
Just a few stragglers left. Good enough for now.
b1370bd
to
c5c2d75
Compare
What type of PR is this? (check all applicable)
Description
Investigation of performance issues indicates the main factor is the change of
reselect
's default memoization function fromlruMemoize
toweakMapMemoize
. This changed in the RTK v2 release (v2 depends on thereselect
v5, which includes this change).lruMemoize
provides a less sophisticated memoize strategy, with a configurable, but finite, cache size. We've never changed it from the default cache size of 1. Instead, we wrap parameterized selectors inuseMemo
and rely on closures to provide the selector parameters. The cache size never grows.weakMapMemoize
provides an effectively unbounded cache size out of the box. When selectors are reused with different parameters, the cache grows.For our particular use patterns, with many parameterized selectors, this substantially increases memory allocations and causes a frequent major GCs. This is my best estimation of the situation and there may be more nuance of course.
Previously (between v3.4.0post2/v3.5.1 and now), I had configured most of the app to use
lruMemoize
, but there were two missing spots:createEntityAdapter
'sgetSelectors()
defaults toweakMapMemoize
, changed tolruMemoize
in this PR.weakMapMemoize
internally, but there's no way to change. Pending a change upstream to allow customizing the memoize function, I've directly patched the builds so thatlruMemoize
is always used.In my profiling, this has smoothed out the remaining bumps, but it's possible that other changes introduced after v3.4.0post2 were also contributing and we still have a few places to fix up.
Related Tickets & Documents
QA Instructions, Screenshots, Recordings
Test canvas and workflow editor. Should be smooth. If there are still performance issues I'll need to continue investigating.
Merge Plan
This PR can be merged when approved.