-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Avoid unnecessary expensive call to getTransactionDetails #45529
Conversation
Shall I review this as C+? |
On this part:
I'd argue because we're making an assumption here that is not backed by any numbers yet. Do you think you can provide some? Maybe we can ask Jason to record the very same workflow on an ad hoc build so we can benchmark few of these runs (as we don't yet have performance tests for this in place). At the same time I'd love to have someone try benchmark this with Reassure as even local measurements should be enough to help us decide here. Do you think that'd be helpful? |
FYI In the meantime I'm working on a fix & explanation for this underlying problem. If you know that calculating these in the first place doesn't make sense though, it's still valuable to pursue this update to the logic itself. |
Yeah it's a bit of an assumption, but I'm not sure that really matters. In the provided screenshot we can see that getTransactionDetails took 36% of the time, of which getFormattedCreated was most of it, so if we remove the call to it then we should see about a 36% speed up.
Yeah we could do that, but what problem does it solve? What are we trying to decide?
Yeah, that's what I'm thinking with this PR. Removing unnecessary computation seems like a no brainer and I don't think we need to measure it carefully right now. |
Thanks for offering, but I don't think we really need a C+ review / testing for this particular PR. |
Oh just wanted to get a basic confirmation before we roll this to everyone. |
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.
Changes LGTM, minor comments
@@ -6426,7 +6427,7 @@ function getIOUReportActionDisplayMessage(reportAction: OnyxEntry<ReportAction>, | |||
} | |||
return Localize.translateLocal(translationKey, { | |||
formattedAmount, | |||
comment: transactionDetails?.comment ?? '', | |||
comment: TransactionUtils.getDescription(transaction) ?? '', |
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.
NAB, should this be called TransactionUtils.getComment
?
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.
I guess description works for now since we are calling it like this in App
const report = getReportOrDraftReport(transaction?.reportID); | ||
const amount = TransactionUtils.getAmount(transaction, !isEmptyObject(report) && isExpenseReport(report)) ?? 0; | ||
const formattedAmount = CurrencyUtils.convertToDisplayString(amount, TransactionUtils.getCurrency(transaction)) ?? ''; | ||
const comment = (!TransactionUtils.isMerchantMissing(transaction) ? TransactionUtils.getMerchant(transaction) : TransactionUtils.getDescription(transaction)) ?? ''; | ||
if (ReportActionsUtils.isTrackExpenseAction(reportAction)) { | ||
return Localize.translateLocal('iou.threadTrackReportName', {formattedAmount, comment}); | ||
} |
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.
should we also move this block up?
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.
can we? it relies on the formattedAmount
and comment
being defined 🤔
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.
Lets explore this later if its possible?
Awesome tweak, thanks @neil-marcellini! As @adhorodyski mentioned, we will target underlying issue in further perspective and this is a great starting point to mitigate negative impact entirely 🙇 Q: Apart from mentioned |
@neil-marcellini a little update from my end, nothing new though:
100% for merging this PR asap ✅ |
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / SafariMacOS: Desktop |
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.
Moving this ahead given this should be a noticeable improvement in the App
const report = getReportOrDraftReport(transaction?.reportID); | ||
const amount = TransactionUtils.getAmount(transaction, !isEmptyObject(report) && isExpenseReport(report)) ?? 0; | ||
const formattedAmount = CurrencyUtils.convertToDisplayString(amount, TransactionUtils.getCurrency(transaction)) ?? ''; | ||
const comment = (!TransactionUtils.isMerchantMissing(transaction) ? TransactionUtils.getMerchant(transaction) : TransactionUtils.getDescription(transaction)) ?? ''; | ||
if (ReportActionsUtils.isTrackExpenseAction(reportAction)) { | ||
return Localize.translateLocal('iou.threadTrackReportName', {formattedAmount, comment}); | ||
} |
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.
Lets explore this later if its possible?
@@ -6426,7 +6427,7 @@ function getIOUReportActionDisplayMessage(reportAction: OnyxEntry<ReportAction>, | |||
} | |||
return Localize.translateLocal(translationKey, { | |||
formattedAmount, | |||
comment: transactionDetails?.comment ?? '', | |||
comment: TransactionUtils.getDescription(transaction) ?? '', |
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.
I guess description works for now since we are calling it like this in App
🚀 Deployed to staging by https://github.com/mountiny in version: 9.0.10-2 🚀
|
🚀 Cherry-picked to staging by https://github.com/mountiny in version: 9.0.10-3 🚀
@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes. |
🚀 Deployed to production by https://github.com/mountiny in version: 9.0.10-7 🚀
|
🚀 Deployed to production by https://github.com/francoisl in version: 9.0.11-5 🚀
|
Details
From this profile trace we can see that 36% of the time for
getOrderedReportIDs
is spent on getting these transaction details, specificallyTransactionUtils.getFormattedCreated
. However, that field not used within thegetTransactionReportName
function so it's a complete waste. Now we'll only extract the specific transaction fields that are needed, when they are needed. It should speed up ordering the LHN by about 36%.Related Issues
#45528
PROPOSAL: N/A
Tests
N/A
Offline tests
N/A
QA Steps
No QA
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop