Repository navigation
[Audit][Implementation] - Reduce Redundant Operations - #37200
roryabraham merged 23 commits into
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] |
roryabraham
left a comment
There was a problem hiding this comment.
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.
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 |
left a comment
There was a problem hiding this comment.
Looks good to me.
cc @roryabraham
commented
Mar 14, 2024
|
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! |
commented
Mar 18, 2024
|
@roryabraham looks like this was merged without a test passing. Please add a note explaining why this was done and remove the |
commented
Mar 18, 2024
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
commented
Mar 19, 2024
|
🚀 Deployed to staging by https://github.com/roryabraham in version: 1.4.55-0 🚀
|
commented
Mar 20, 2024
|
🚀 Deployed to staging by https://github.com/roryabraham in version: 1.4.55-0 🚀
|
commented
Mar 22, 2024
|
🚀 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 toparsePhoneNumberis 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 Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel so the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.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