-
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
[Audit][Implementation] - Reduce Redundant Operations #37200
[Audit][Implementation] - Reduce Redundant Operations #37200
Conversation
@youssef-lr Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
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.
Since this is a performance-related PR, can you please update the PR description to include benchmarks?
marking this as WIP at least until the caching/memoization/dynamicProgramming has been moved to the existing translation lib |
…y-App into audit/app-startup/reduce-redundant-op
@roryabraham Thanks for the review and the discussion. I have accommodated all of the feedbacks including the cache mechanism for translations. Only feedback that's not addressed is regarding the For Below is a screenshot from Hermes trace with Below is a screenshot from Hermes trace with The execution time is more or less the same BUT the main gain is from not testing a string against a RegExp, which doesn't contain the I would like to have a discussion about how do you guys like to avoid testing a string against a RegExp, which doesn't contain the The below code is what we have now, which helps us not to do substring replacement, if string doesn't starts with let displayName = passedPersonalDetails?.displayName ?? '';
// If the displayName starts with the merged account prefix, remove it.
if (displayName.startsWith(CONST.MERGED_ACCOUNT_PREFIX)) {
displayName = displayName.substring(substringStartIndex);
} Some explanation on In the attached screenshot, we already have a helper function We can go about it two ways:
Let me know what you think about it 👍 I also want to share the impact of cache mechanism in translations. I profiled the Android App startup on an account with ~15k reports and below is a snapshot from the hermes trace. Without cache: With cache: We can see that in Without cache the |
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.
Otherwise, LGTM. though I do want to wait for @fedirjh to review, test, and complete the checklist before we merge this
Cool, now just waiting for @fedirjh to complete the checklist, which he said he will do soon. |
@fedirjh I have addressed your feedback regarding moving cache to Also, below we can see that we save around ~1344 times translating some phrases that's already translated. Again, thanks for highlighting the right place for the cache 💯 |
…y-App into audit/app-startup/reduce-redundant-op
Reviewer Checklist
Screenshots/VideosAndroid: mWeb ChromeCleanShot.2024-03-14.at.13.46.44.mp4iOS: NativeSimulator.Screen.Recording.-.iPhone.Xs.-.2024-03-14.at.14.06.02.mp4iOS: mWeb SafariSimulator.Screen.Recording.-.iPhone.Xs.-.2024-03-14.at.14.15.47.mp4MacOS: DesktopCleanShot.2024-03-14.at.14.19.52.mp4 |
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.
Looks good to me.
cc @roryabraham
We did not find an internal engineer to review this PR, trying to assign a random engineer to #33070 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
@roryabraham looks like this was merged without a test passing. Please add a note explaining why this was done and remove the |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/roryabraham in version: 1.4.55-0 🚀
|
🚀 Deployed to staging by https://github.com/roryabraham in version: 1.4.55-0 🚀
|
🚀 Deployed to production by https://github.com/AndrewGable in version: 1.4.55-3 🚀
|
Details
Part of Callstack Performance Audit.
This PR removes the redundant operations like static translation that happens on each loop iteration and this PR also checks beforehand whether the number to parse is a valid phone number and if it is, only then the number is parsed by
parsePhoneNumber
. The reason is that call toparsePhoneNumber
is costly and should only be executed for the numbers that are valid.Fixed Issues
$ #37275
PROPOSAL: #35234 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.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 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.mov
Android: mWeb Chrome
android-web.mov
iOS: Native
ios.mov
iOS: mWeb Safari
ios-web.mov
MacOS: Chrome / Safari
web.mov
MacOS: Desktop
desktop.mov