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] Reduce the amount of expensive getOptions calls in Request Money flow #39133

Closed
mountiny opened this issue Mar 27, 2024 · 13 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@mountiny
Copy link
Contributor

mountiny commented Mar 27, 2024

Problem

When using Request Money flow, the getOptions function is called multiple times, doing heavy operations and slowing down the app. Based on a provided trace, a single execution of this function takes ~2.5s, and it is called when the following actions are performed:

  • entering the Request Money participants list
  • typing in the search input (each keystroke)
  • pressing the option from the list
  • pressing “split” on the option item

Additionally, the server search to get reports is also called on each keystroke.

All of this is making the app unresponsive for a long time, making it difficult to reach the next step of the money request process. The total amount of getOptions execution time in a provided trace was 29.7s.

Solution

To address this problem, we should reduce the amount of getOptions calls to minimum. We can achieve this by:

  • using debounced state instead of calling the function on each keystroke - this way we call getOptions and server search only when user is not typing in the input anymore
  • properly memoizing the participants selector component - selecting the user from the list is updating the transaction, which triggers the heavy operation even if the participants list hasn’t changed

There is still need of calling the function when pressing “Split”, but there is a possibility we would be able to replace it with filtering once it’s implemented in the list (this is one of the efforts from the performance audit).
Considering the following scenario:

  1. User requests money and goes to participants list
  2. User types “workspace” in the search
  3. User presses the selected option item

Before changes the getOptions was called 16 times, and after it is called 2 times.

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~019e025ca125dedd18
  • Upwork Job ID: 1773283266133659648
  • Last Price Increase: 2024-03-28
Issue OwnerCurrent Issue Owner: @slafortune
@mountiny mountiny added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Mar 27, 2024
@mountiny mountiny self-assigned this Mar 27, 2024
Copy link

melvin-bot bot commented Mar 27, 2024

Triggered auto assignment to @slafortune (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@mountiny mountiny added the Reviewing Has a PR in review label Mar 27, 2024
@TMisiukiewicz
Copy link
Contributor

Hey, I'm Tomasz from Callstack and I want to work on this issue

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

melvin-bot bot commented Mar 28, 2024

Job added to Upwork: https://www.upwork.com/jobs/~019e025ca125dedd18

@melvin-bot melvin-bot bot changed the title [Performance] Reduce the amount of expensive getOptions calls in Request Money flow [$500] [Performance] Reduce the amount of expensive getOptions calls in Request Money flow Mar 28, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Mar 28, 2024
Copy link

melvin-bot bot commented Mar 28, 2024

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

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Mar 28, 2024
@mountiny mountiny removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Mar 28, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 labels Apr 2, 2024
@melvin-bot melvin-bot bot changed the title [$500] [Performance] Reduce the amount of expensive getOptions calls in Request Money flow [HOLD for payment 2024-04-09] [$500] [Performance] Reduce the amount of expensive getOptions calls in Request Money flow Apr 2, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Apr 2, 2024
Copy link

melvin-bot bot commented Apr 2, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

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 fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@akinwale] The PR that introduced the bug has been identified. Link to the PR:
  • [@akinwale] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@akinwale] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@akinwale] Determine if we should create a regression test for this bug.
  • [@akinwale] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@slafortune] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@mountiny
Copy link
Contributor Author

mountiny commented Apr 2, 2024

$500 to @akinwale

@slafortune
Copy link
Contributor

@mountiny @akinwale I believe that no regression test will be needed for this, can you confirm?

@mountiny
Copy link
Contributor Author

mountiny commented Apr 2, 2024

No regression tests required here

@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

  • ROLE: @akinwale paid $(AMOUNT) via Upwork (LINK)
  • Contributor: @TMisiukiewicz is from an agency-contributor and not due payment

BugZero Checklist (@slafortune)

  • 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/1773283266133659648/hired)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

@slafortune
Copy link
Contributor

@akinwale please the offer sent here $500
@TMisiukiewicz is from an agency-contributor and not due payment

@akinwale
Copy link
Contributor

akinwale commented Apr 9, 2024

@slafortune Accepted. Thanks!

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 Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
Development

No branches or pull requests

4 participants