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

[HOLD for payment 2024-04-09] [$500] [Performance] Refactor our current Onyx.connect calls to Reports to include waitForCollectionCallback #38586

Closed
muttmuure opened this issue Mar 19, 2024 · 13 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Daily KSv2 External Added to denote the issue can be worked on by a contributor NewFeature Something to build that is a new item.

Comments

@muttmuure
Copy link
Contributor

muttmuure commented Mar 19, 2024

Problem

We have lots of connections to Reports data in Onyx in our utils files and some of them uses waitForCollectionCallback: true and the rest of them don’t. Which adds up to the app startup time. The reason is that when we don’t set waitForCollectionCallback to true in Onyx.js the following code is executed:

// Onyx.js

if (mapping.waitForCollectionCallback) {
    getCollectionDataAndSendAsObject(matchingKeys, mapping);
    return;
}

 // We did not opt into using waitForCollectionCallback mode so the callback is called for every matching key.
for (let i = 0; i < matchingKeys.length; i++) {
    get(matchingKeys[i]).then((val) => sendDataToConnection(mapping, val, matchingKeys[i], true));
}

This loop will be executed for all the keys and will individually inform the subscriber of updates. The get function first checks whether the value for a key is present in cache and if it doesn’t it then gets it from the storage.
We have 6 connections to Reports without the waitForCollectionCallback so this loop will be executed 6 times. Bearing in mind that Reports can be a huge collection, for eg on a heavy account it can get to 15k reports.

Solution

We can consider to refactor our current Onyx.connect calls to Reports to include waitForCollectionCallback and adjust the code accordingly. There’s one place where we won’t be changing it and that’s in ReportUtils.ts where we have to call handleReportChanged on each report.
One more thing to notice is that currently our cache limit is 10k which is easily hit by a heavy account of 15k reports, so this cache limit isn’t helping the app in case of a heavy account. We can increase it to 20k so that it can hold more reports. Hermes traces are attached in the PR description.
To summarise, When launching the app on Android:

We get 32 seconds of TTI ----- on baseline, which is what we currently have 🔴
We get 25 seconds of TTI ----- with improvements by adding waitForCollectionCallback :large_green_circle:
We get 18 seconds of TTI ----- with increased cache limit to 20k and improvements by adding waitForCollectionCallback :large_green_circle: :large_green_circle:

From: @hurali97

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~012ebdb211b4ffdbac
  • Upwork Job ID: 1770120318947196928
  • Last Price Increase: 2024-03-19
Issue OwnerCurrent Issue Owner: @isabelastisser
@muttmuure
Copy link
Contributor Author

#38464

@mountiny mountiny self-assigned this Mar 19, 2024
@mountiny mountiny added the NewFeature Something to build that is a new item. label Mar 19, 2024
Copy link

melvin-bot bot commented Mar 19, 2024

@melvin-bot melvin-bot bot added the Weekly KSv2 label Mar 19, 2024
@mountiny mountiny added the External Added to denote the issue can be worked on by a contributor label Mar 19, 2024
Copy link

melvin-bot bot commented Mar 19, 2024

Job added to Upwork: https://www.upwork.com/jobs/~012ebdb211b4ffdbac

@melvin-bot melvin-bot bot changed the title [Performance] Refactor our current Onyx.connect calls to Reports to include waitForCollectionCallback [$500] [Performance] Refactor our current Onyx.connect calls to Reports to include waitForCollectionCallback Mar 19, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Mar 19, 2024
Copy link

melvin-bot bot commented Mar 19, 2024

Current assignee @shubham1206agra is eligible for the External assigner, not assigning anyone new.

@melvin-bot melvin-bot bot added the Daily KSv2 label Mar 19, 2024
@mountiny mountiny removed Daily KSv2 Help Wanted Apply this label when an issue is open to proposals by contributors labels Mar 19, 2024
@melvin-bot melvin-bot bot removed the Weekly KSv2 label Mar 19, 2024
@mountiny mountiny added the Weekly KSv2 label Mar 19, 2024
@mountiny
Copy link
Contributor

Handled by callstack

@melvin-bot melvin-bot bot added the Overdue label Apr 1, 2024
@isabelastisser
Copy link
Contributor

Hey @mountiny, can you please clarify if this is fixed and can be closed? Thanks!

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Overdue Weekly KSv2 labels Apr 2, 2024
@melvin-bot melvin-bot bot changed the title [$500] [Performance] Refactor our current Onyx.connect calls to Reports to include waitForCollectionCallback [HOLD for payment 2024-04-09] [$500] [Performance] Refactor our current Onyx.connect calls to Reports to include waitForCollectionCallback Apr 2, 2024
Copy link

melvin-bot bot commented Apr 2, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.58-8 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-04-09. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Apr 2, 2024

BugZero Checklist: The PR adding this new feature has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@shubham1206agra] Please propose regression test steps to ensure the new feature will work correctly on production in further releases.
  • [@isabelastisser] Link the GH issue for creating/updating the regression test once above steps have been agreed upon.

@mountiny
Copy link
Contributor

mountiny commented Apr 2, 2024

$500 to @shubham1206agra for testing and review, then we can close, thank you!

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Apr 8, 2024
Copy link

melvin-bot bot commented Apr 9, 2024

Payment Summary

Upwork Job

BugZero Checklist (@isabelastisser)

  • I have verified the correct assignees and roles are listed above and updated the neccesary manual offers
  • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1770120318947196928/hired)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

@melvin-bot melvin-bot bot added the Overdue label Apr 10, 2024
@isabelastisser
Copy link
Contributor

Hey @shubham1206agra, sorry for the delay. I hired you in Upwork, please accept it and I will process the payment ASAP. Thanks!

@github-project-automation github-project-automation bot moved this from CRITICAL to Done in [#whatsnext] #quality Apr 10, 2024
@melvin-bot melvin-bot bot removed the Overdue label Apr 10, 2024
@shubham1206agra
Copy link
Contributor

@isabelastisser I have discussed this internally here. You may close this issue as I am keeping track of payment internally and will ask to pay once the issue is resolved. Just write in the payment summary that I have not been paid yet.

@shubham1206agra
Copy link
Contributor

@isabelastisser You can process payment here now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Daily KSv2 External Added to denote the issue can be worked on by a contributor NewFeature Something to build that is a new item.
Projects
Development

No branches or pull requests

4 participants