-
Notifications
You must be signed in to change notification settings - Fork 74
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: use idb-keyval #293
Perf: use idb-keyval #293
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.
Looks great! Any idea how can we test this in product? 🚀
@marcaaron could you please review, as you have better context of the issue |
I would try this:
|
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.
Maybe we should just remove all traces of localforage
if nothing will use it? 🤔
import fastMerge from '../../fastMerge'; | ||
|
||
// Same config as localforage, so we can swap the providers easily | ||
const customStore = createStore('OnyxDB', 'keyvaluepairs'); |
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.
confirming: This will have the existing data from the current DB previously set up by localforage
?
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.
Yes exactly 😊 It can just be replaced in place
@marcaaron You mean to delete the provider file? |
👍 |
Alright, I removed all traces of local forage 😊 |
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.
NAB @hannojg maybe we can benchmark Onyx.clear
as well since I know there are some race conditions around it and it's unclear how well the localforage-removeItems
plugin ever actually worked
oh yeah great thought @roryabraham! adding to that point, I think the place where I see this slowing things down the most is when someone signs out of an account with a ton of data. so we should be sure to A/B test that flow and see if things improved. |
I don't think this is blocker for merging this PR since we don't know if the old one actually worked, right? It would be great to have this merged Today so we can see the benefits for this mostly in Guides and AM accounts |
Let me fix the benchmark for clearing and give numbers for that 😊 With this implementation deleting / clearing should definitely work |
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.
Thanks @hannojg
The changes look good to me and seems like the concerns of Marc and Rory has been addressed as well. I think it would be great to test this one out in the App so given that @danieldoglas and @MonilBhavsar are approving of this too, it could hopefully improve the Guides open app start time masivelly so I will go ahead and merge this and Margelo can put up a PR with the bump
Are we sure this is faster than the previous solution of setting one value at a time synchronously? Did we verify that things improved on a large account? Which account did we test with?
Is is possible we can ask it to do too many at once? I am seeing various weird logs like:
|
I believe @hannojg is on vacation @Szymon20000 Would you be able to look into the above? |
I will try but my focus this week is on improving chat switching and batching updates. |
Added to my todo list! |
Details
While investigating performance issues on large accounts we found an issue where storing large amounts of data in onyx takes a very long time (E.g. merging the data from a OpenApp command).
Largely this was due to the underlying storage provider opening a new database transaction for every operation in a multiMerge/multiSet operation.
The idb-keyval package optimises this, as it can handle multiple operations in one database transaction.
The good thing is, that
idb-keyval
also uses indexedDB as storage provider, so no migration is needed.I created a performance comparison tool, and it showed how much better
idb-keyval
performs:How to run the performance tests yourself:
cd example
npm i
npm start
http://localhost:8080
For the product the results can be seen in this video:
https://expensify.slack.com/archives/C035J5C9FAP/p1691063111819169
Related Issues
#281
Automated Tests
Linked PRs