-
Notifications
You must be signed in to change notification settings - Fork 4k
Improve the performance of report name generation #12399
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
Changes from all commits
560f2f6
363ece2
c2247a1
8b96341
722a71e
6e927c9
4b0bcb2
39e5787
83f248f
22a84bb
acb64f8
4207f10
172eaf7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -100,11 +100,12 @@ function getOrderedReportIDs(reportIDFromRoute) { | |||||||||||||||||||||||||
| // Get all the display names for our reports in an easy to access property so we don't have to keep | ||||||||||||||||||||||||||
| // re-running the logic | ||||||||||||||||||||||||||
| const filteredReportsWithReportName = _.map(filteredReports, (report) => { | ||||||||||||||||||||||||||
| const personalDetailMap = OptionsListUtils.getPersonalDetailsForLogins(report.participants, personalDetails); | ||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||
| ...report, | ||||||||||||||||||||||||||
| reportDisplayName: ReportUtils.getReportName(report, personalDetailMap, policies), | ||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||
| // Normally, the spread operator would be used here to clone the report and prevent the need to reassign the params. | ||||||||||||||||||||||||||
| // However, this code needs to be very performant to handle thousands of reports, so in the interest of speed, we're just going to disable this lint rule and add | ||||||||||||||||||||||||||
| // the reportDisplayName property to the report object directly. | ||||||||||||||||||||||||||
| // eslint-disable-next-line no-param-reassign | ||||||||||||||||||||||||||
|
Comment on lines
+103
to
+106
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nifty 👍 I can't think of any downside to this, worst case is
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here we are 😁 This tricked us that we were using
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I strongly disagree with allowing mutations into our code, it creates hard to debug bugs and is hard to track the states of objects.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now there is a second property getting mutated below this one: Lines 112 to 113 in c32fb5a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fine with finding a way to remove the mutations as long as the code remains performant.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not totally sure but I think we can leave the mutation now since we are mutating a clone. I don't see much benefit in cloning a clone.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess that makes it a bit better because we are only mutating the copy we pass down this tree, right? App/src/pages/home/sidebar/SidebarLinksData.js Lines 150 to 159 in fe8aeb8
Still a bad practice in react to mutate props in general, you have to follow up from where the prop is coming to verify that this is not causing more side effects and it is also hard to assure that things are getting rendered when they should down the line.
That is fair, do you know how to reproduce the performance issues?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The best way to ensure it doesn't regress on performance is to add some timers around this code, and then time it before/after making the change. |
||||||||||||||||||||||||||
| report.reportDisplayName = ReportUtils.getReportName(report, policies); | ||||||||||||||||||||||||||
| return report; | ||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // Sorting the reports works like this: | ||||||||||||||||||||||||||
|
|
@@ -296,7 +297,7 @@ function getOptionData(reportID) { | |||||||||||||||||||||||||
| result.payPalMeAddress = personalDetail.payPalMeAddress; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const reportName = ReportUtils.getReportName(report, personalDetailMap, policies); | ||||||||||||||||||||||||||
| const reportName = ReportUtils.getReportName(report, policies); | ||||||||||||||||||||||||||
| result.text = reportName; | ||||||||||||||||||||||||||
| result.subtitle = subtitle; | ||||||||||||||||||||||||||
| result.participantsList = personalDetailList; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
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.
Just wondering, why use
logins[0]here instead ofpersonalDetail.loginlike the following 2 lines?