-
Notifications
You must be signed in to change notification settings - Fork 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
[Performance] Onyx.clear() takes a long time and can leave stale data in storage #13884
Comments
cc @fedirjh |
Note to self: there is a plugin for LocalForage which provides |
I'm going to move this to be weekly since I need to do some performance testing on it and we've got a busy week in the office. |
@tgolen I've captured some metrics for
note: These tests are related to
ProblemFrom above results we can tell that SolutionWe can use // If we just call Storage.clear other tabs will have no idea which keys were available previously
// so that they can call keysChanged for them. That's why we iterate and remove keys one by one
this.clear = () => Storage.getAllKeys()
.then(keys => _.map(keys, key => this.removeItem(key)))
.then(tasks => Promise.all(tasks)); @kidroca is this the only limitation for using |
@fedirjh Thanks for that initial investigation. There has been a string of problems that we have run into which makes Primarly, it's because there are a small handful of keys that we don't want to be removed (preferred locale for example). What we were doing before was:
This unfortunately, leads to a flash of text as it changes back and forth from different languages. The idea then is that we should try to clear every key except the ones we want to keep. That's why it uses I think we should continue down this path rather than going back to trying to use What I would like to do next is see about implementing the |
@tgolen I checked that , you mean the |
https://github.com/Expensify/App/blob/main/src/libs/actions/SignInRedirect.js#L40-L43 |
You might be right though that once the |
Yes that's the point , we only update the clear method to reset keys after clear return Storage.clear(defaultKeyValuePairs); and in here this.clear = (keysToDefault) => Storage.clear().then(() => Storage.multiSet(keysToDefault)); |
OK, got it, thanks! How would you update that to account for the values I pointed to (just so I am clear on what you are proposing)? |
I think those values are stored locally before we call const activeClients = currentActiveClients;
const preferredLocale = currentPreferredLocale;
const isOffline = currentIsOffline;
const shouldForceOffline = currentShouldForceOffline; |
OK, I don't think I'm totally following you, but regardless, I've tried this:
and it appears to be several times slower (like 2-3x) than using So maybe there is something that I'm not quite grasping with the timing of |
@tgolen I think you missed my comment , here is diff Changes in Onyx.js - return Storage.multiSet(keyValuesToReset);
+ return Storage.clear(defaultKeyValuePairs); Changes in WebStorage.js - this.clear = () => Storage.getAllKeys()
- .then(keys => _.map(keys, key => this.removeItem(key)))
- .then(tasks => Promise.all(tasks));
+ this.clear = (keysToDefault) => Storage.clear().then(() => Storage.multiSet(keysToDefault)); |
Ah, thank you for the clear diffs. That makes more sense now! I keep forgetting of I'm timing this in |
@tgolen can you set this account ( fedidev+ht@gmail.com ) for 4K reports ? I did tested with 1K account and results are ~200 ms |
Hm, I don't think I can. I'm just testing this in my local environment. I
can send you credentials for a high traffic account on staging through.
Please send me a DM in slack to @tgolen
…On Mon, Jan 2, 2023 at 4:34 PM Fedi Rajhi ***@***.***> wrote:
@tgolen <https://github.com/tgolen> can you set this account (
***@***.*** ) for 4K reports ? I did tested with 1K account and
results are ~200 ms
—
Reply to this email directly, view it on GitHub
<#13884 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJMAB4WAMODHUEKSN2LSFDWQNXYDANCNFSM6AAAAAATMGUI7U>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
OK, the results are looking pretty good now. It appears that the times when it takes a while depends on how quickly you sign out after signing in. For these times that are high, I am signing out about 2-3 seconds after signing in. There must just be a lot of data being put into Onyx which slows things down. If I wait about 15-20 seconds before signing out, then it is very fast to clear. |
Unfortunately, even with this improvement, if you signout quickly, and refresh (before the timing event has fired) then you still end up with report data in Onyx 😞 But, I guess this is still better than what we had before, even if it doesn't fully solve the problem. |
Triggered auto assignment to @davidcardoza ( |
Bug0 Triage Checklist (Main S/O)
|
@davidcardoza I think you can ignore some of the above. I just needed to assign it to BZ so that @mollfpr could get paid (I think) |
If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results. If a regression has occurred and you are the assigned CM follow the instructions here. If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future. |
bump @davidcardoza |
@mollfpr I extended a contract to you via Upwork |
@davidcardoza Accepted, thank you! Also, is a bonus apply to internal PR review? |
@tgolen am I not eligible for compensation here ? |
Oh, maybe I am a little confused here. @mollfpr why are you requesting payment for this? I don't see you providing any proposals or helping out at all. @fedirjh I am fine with you having some compensation for your comments in this GH which were helpful for me in writing the solution. I am OK with compensating you with $250 for your help. |
@tgolen Sorry for the confusion, I got assigned to review the PR. |
Oh, right. I was only looking at the |
Thanks for flagging @fedirjh I should have caught your contribution. My fault I will process the contract in Upwork. |
@davidcardoza mind tackling payment to @fedirjh when they accept? |
@tgolen, @davidcardoza, @mollfpr 12 days overdue. Walking. Toward. The. Light... |
@fedirjh did you accept? I am having trouble locating the offer sent by @dylanexpensify |
@davidcardoza yep accepted |
Hmmm...Can you link me to the post you accepted? I am not seeing you in the hired or proposal sections of the job posting |
@davidcardoza That’s my Upwork profile 😅 I’ll already get the payment from Dylan. |
Sorry my comment comment was for @fedirjh you can ignore. |
This comment was marked as off-topic.
This comment was marked as off-topic.
great, closing this out then! |
@davidcardoza the offer is accepted but payment isn't yet issued 😅 |
Payment sent. |
What performance issue do we need to solve?
When Onyx.clear() takes a long time to work, and if the browser is refreshed or closed during the process, it can leave stale data in storage.
What is the impact of this on end-users?
The next user that signs in can then see data from the previous user.
List any benchmarks that show the severity of the issue
TBD
Proposed solution (if any)
Provide a better mechanism to ensure Onyx is cleared fully before redirecting users to the sign out page. Possibly put something in place that prevents the browser from being refreshed while
clear()
is happening. Also possibly speed up the time it takes for Onyx.clear() to work.List any benchmarks after implementing the changes to show impacts of the proposed solution (if any)
TBD
Platforms:
Which of our officially supported platforms is this issue occurring on?
Previous mentions of bugs caused by this:
The text was updated successfully, but these errors were encountered: