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

Edit command is slow #13742

Closed
iwiznia opened this issue Dec 20, 2022 · 60 comments
Closed

Edit command is slow #13742

iwiznia opened this issue Dec 20, 2022 · 60 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering Internal Requires API changes or must be handled by Expensify staff Reviewing Has a PR in review

Comments

@iwiznia
Copy link
Contributor

iwiznia commented Dec 20, 2022

Context https://expensify.slack.com/archives/C03TQ48KC/p1671566294965399

Problem

UpdateComment and really Report_EditComment too (they use the same code) are slow.
Mostly, it is caused by fully loading and instantiating all the report history.

Solution

Instead of loading the whole history, to then call ReportUtils::getMostRecentVisibleAction and ReportUtils::getMostRecentVisibleUnreadAction, we should have auth return those values by querying them directly in the DB and only returning the data we need.

BTW this will not be fixed by the deprecate sequence numbers project, so it needs to be done separately.

cc @chiragsalian

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~016ec925fa79763af8
  • Upwork Job ID: 1605317751109066752
  • Last Price Increase: 2022-12-20
@iwiznia iwiznia added Engineering Weekly KSv2 Internal Requires API changes or must be handled by Expensify staff Bug Something is broken. Auto assigns a BugZero manager. labels Dec 20, 2022
@melvin-bot melvin-bot bot locked and limited conversation to collaborators Dec 20, 2022
@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Dec 20, 2022
@luacmartins luacmartins self-assigned this Dec 20, 2022
@luacmartins
Copy link
Contributor

So it seems like we want to create a new Auth command, e.g. getMostRecentVisibleAction that will return the most recent visible action or the most recent visible unread action to PHP so we can stop calling $report->getHistory(). Does that sound right @iwiznia?

@iwiznia
Copy link
Contributor Author

iwiznia commented Dec 22, 2022

Yeah maybe... I am not that familiar with this flow, like why do we care about the most recent visible action?

@luacmartins
Copy link
Contributor

From what I can tell, it seems to be used to:

  1. Update the last message text in the LHN if we edited the most recent message
    Screenshot 2022-12-22 at 2 02 36 PM

  2. Update the unread count if we deleted the last unread message

@luacmartins
Copy link
Contributor

Maybe we don't need a new command and we can move that logic to UpdateReportComment in Auth. I'll explore that first since it would most align with our 1:1:1 goal.

@iwiznia
Copy link
Contributor Author

iwiznia commented Dec 22, 2022

The last 1 of 1:1:1 was not decided and I expressed my concern about it many times before: adding reads to a write makes the command more likely to conflict, so I am not sure if it's best to add it in that command or have a separate one.

@luacmartins
Copy link
Contributor

Makes sense, I think in that case a new command is better.

@luacmartins
Copy link
Contributor

I'm going ooo until Jan 3, so I'll unassign myself in case someone else wants to work on this while I'm away.

I have some draft PRs (Web-E and Auth), but they are far from being ready. If anyone picks this up, feel free to use/discard my draft PRs. If nobody picks this up, I'll come back to it in January!

@luacmartins luacmartins removed their assignment Dec 23, 2022
@JmillsExpensify
Copy link

Thanks for the heads up! I'm trying to wrap my head around the importance of this. My initial sense is that it's importance for Expensify employees but not particularly important for WAQ. So we should solve it but it's not critically pressing. Does that sound right to others on this issue?

@melvin-bot melvin-bot bot added the Overdue label Dec 26, 2022
@JmillsExpensify JmillsExpensify added Bug Something is broken. Auto assigns a BugZero manager. and removed Bug Something is broken. Auto assigns a BugZero manager. labels Dec 27, 2022
@JmillsExpensify
Copy link

Re-added the bug label so that we can get someone else on this over the holidays. And....that didn't work. Going with the engineering label instead.

@JmillsExpensify
Copy link

@sketchydroide Do you think you'll have time to help move this forward this week? Carlos has two draft PRs up as a starting point.

@sketchydroide
Copy link
Contributor

Yeah, I can help with this, if I get stuck, I'll be sure to ask for help, but for now I think I understand the core of it

@JmillsExpensify
Copy link

Awesome, thanks!

@sketchydroide
Copy link
Contributor

I've started work on it, kept the changes of Carlos, and working on top of the original PRs
I think I have a good grasp of what is needed, I think most of the changes wil be on Auth and then Web is mostly cleanup, although I think I need to create a command for getMostRecentVisibleUnreadAction both on Auth and Web.

This is the one that used the lastReadSequenceNumber that I will not use, will use the timeStamp instead as per the new deprecate sequenceNumber doc.

@sketchydroide
Copy link
Contributor

Thanks @iwiznia for the comments on the PR, will go through them today

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Feb 6, 2023
@sketchydroide
Copy link
Contributor

Auth PR is done, and I will put it for review tomorrow
Web should be very close, it's much smaller, it might need some work on the App

@melvin-bot melvin-bot bot removed the Overdue label Feb 8, 2023
@sketchydroide
Copy link
Contributor

ok Auth PR is now ready for review

@melvin-bot melvin-bot bot added the Overdue label Feb 13, 2023
@JmillsExpensify
Copy link

Looks like we're still working through the linked Auth PR.

@melvin-bot melvin-bot bot removed the Overdue label Feb 14, 2023
@sketchydroide
Copy link
Contributor

It's under review, and there has been some comments on what can be improved, and some doubts poping up
I'll get them sorted today, and maybe get a convo happening if it becomes to complex for a PR.

@sketchydroide sketchydroide added the Reviewing Has a PR in review label Feb 14, 2023
@sketchydroide
Copy link
Contributor

Auth PR seems to be close to being done with the comments

@JmillsExpensify
Copy link

Assigning Ionatan on this as he takes over the linked PR.

@MelvinBot
Copy link

@iwiznia, @JmillsExpensify Whoops! This issue is 2 days overdue. Let's get this updated quick!

@iwiznia
Copy link
Contributor Author

iwiznia commented Feb 23, 2023

Waiting for reviews

@MelvinBot
Copy link

@iwiznia, @JmillsExpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@MelvinBot
Copy link

@iwiznia, @JmillsExpensify Still overdue 6 days?! Let's take care of this!

@MelvinBot
Copy link

@iwiznia, @JmillsExpensify Now this issue is 8 days overdue. Are you sure this should be a Daily? Feel free to change it!

@iwiznia
Copy link
Contributor Author

iwiznia commented Mar 8, 2023

Working on it, conflicts and people reusing a method I had killed delayed this a while, plus it will require waiting for an auth deploy.

@MelvinBot
Copy link

@iwiznia, @JmillsExpensify Whoops! This issue is 2 days overdue. Let's get this updated quick!

@MelvinBot
Copy link

@iwiznia, @JmillsExpensify 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

@MelvinBot
Copy link

@iwiznia, @JmillsExpensify Now this issue is 8 days overdue. Are you sure this should be a Daily? Feel free to change it!

@MelvinBot
Copy link

@iwiznia, @JmillsExpensify 10 days overdue. I'm getting more depressed than Marvin.

@JmillsExpensify
Copy link

Still in progress. Thanks Melvin

@MelvinBot
Copy link

@iwiznia, @JmillsExpensify Huh... This is 4 days overdue. Who can take care of this?

@MelvinBot
Copy link

@iwiznia, @JmillsExpensify Still overdue 6 days?! Let's take care of this!

@iwiznia
Copy link
Contributor Author

iwiznia commented Apr 5, 2023

This is done. I did a few tests and it seems it's fast now.

@iwiznia iwiznia closed this as completed Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering Internal Requires API changes or must be handled by Expensify staff Reviewing Has a PR in review
Projects
None yet
Development

No branches or pull requests

6 participants