-
Notifications
You must be signed in to change notification settings - Fork 20
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
perf(redux): optimize state persist and add slice versions #753
Conversation
There was a little hiccup from
That PR has not been merged for long :(( |
This PR/issue depends on:
|
3a07aea
to
2f05779
Compare
I'm a little concerned about this package given that that PR has been open so long, despite being so small and seemingly low risk. Development activity looks pretty dead in general. What if it stays dead and falls behind the latest Redux versions? Maybe this is an opportunity to re-investigate usage of Redux as a whole, and find something comparable that also offers localStorage persistence? https://github.com/pmndrs/zustand This looks like it operates from a very similar principle to Redux but probably even simpler, and comes with persistence support. Redux probably does better when you have large and complex global application state, but our application state is mostly on the backend actually and all the client state storage is (hopefully) small and simple UI state by design. |
Test image available:
|
Right, there has not been any major dev since Oct 2021. I will look into this new package then. I guess we will move away from Redux then. |
Well, not necessarily. We could stick to Redux since that's quite well established and active, just avoid redux-persist. If there is nothing else out there similar then maybe there are lessons we can take away and implement small pieces of as utilities within our own project at least to improve the local storage performance. |
I think apart from redux-persist, I was exploring writing a custom Redux middleware to persist data but stopped after seeing that package. I could try seeing if I could replicate current behaviour with middleware. |
Frontend notifications could probably also be handled using Redux/Zustand/whatever, now that I think of it. |
This one looks good as well, from a cursory glance. |
@andrewazores Hey, with this latest commits, I tried to write a simple middleware that persists part of the store based on the action. Any new reducer will add another What do you think? Meanwhile I will play around with other packages in case we want to migrate our redux setup to it. |
Test image available:
|
Ready for review again... :D In these latest commits:
|
Test image available:
|
Test image available:
|
If I run a previous build of the web-client and it persists some data into
Going into browser settings and clearing localstorage for |
^ I don't think that behaviour is unique to this PR though, but it might be a good opportunity to address it as well. |
Oh yes there is actually a feature in redux-persist that does migrating previous state. I will look into it and do a simpler version of it. |
I am thinking of doing versioning:
What do you think? |
Sounds like a reasonable plan to me. Would the version be for the store as a whole or per slice? Losing AA card filter states on version updates isn't so bad, but losing dashboard layouts would be very unfortunate. |
I think versioning per slice is more convenient as changes mostly just tough a single slice. |
Agreed, sounds good. I suppose there could actually be a top-level version too which follows the same logic. It would be unlikely to change, but if it did, we would be glad it's versioned. |
Ahh got a little unfortunate here as store state is constructed from reducers. Adding a custom field (i.e. _version) on root state is not allowed... I guess we could just version slices then. |
There is no clean up for localStorage if there is a version mismatch. I think we should let it be in case the user switches to an older version of web console that uses that version. |
Test image available:
|
It would probably only be developers who downgrade to an older version, not end users, so I wouldn't worry too much about trying to maintain storage compatibility in both directions. |
Test image available:
|
Signed-off-by: Thuan Vo <thvo@redhat.com>
8879776
to
88c587b
Compare
Test image available:
|
Welcome to Cryostat! 👋
Before contributing, make sure you have:
main
branch[chore, ci, docs, feat, fix, test]
git commit --amend --signoff
Fixes: #725
Depends on #747 (needs updates on dashboardCondfigReducer)
Description of the change:
This PR includes following changes:
Motivation for the change: