Skip to content

Release profiler - #36414

Merged
srikarparsi merged 28 commits into
Expensify:mainfrom
margelo:perunt/release-profiler
Mar 11, 2024
Merged

srikarparsi merged 28 commits into
Expensify:mainfrom
margelo:perunt/release-profiler

Conversation

@perunt

@perunt perunt commented Feb 13, 2024 •

Copy link
Copy Markdown
Contributor

Usually performance issues are profiled in debug builds, which could lead to false positives (e.g. JS Garbage Collectors, Hermes-specific debug markers, or other LLDB hangs).

react-native-release-profiler allows you to profile your app in release builds, both in a local environment to profile specific issues, as well as in a production environment to spot regressions or collect performance samples from a wider variety of user devices.

This menu should be available in production. That's why I removed isDevelopment checks from src/components/TestToolsModal.tsx

After you've captured the performance trace, you can download and process it from your phone to your PC
On Android:
npx react-native-release-profiler --fromDownload --appId <your appId>

On IOS:
npx react-native-release-profiler --local <path to profile>

Also, after capturing metrics, you are able to share them. In the sharing process, you would see two files

  1. Trace file
  2. App info file which looks like:
const appData = {
    appVersion: "1.0.0",
    environment: 'production',
    platform: "IOS",
    totalMemory: "3GB",
    usedMemory: "300MB"
}

Details

Fixed Issues

$ https://expensify.slack.com/archives/C05LX9D6E07/p1707759274500039?thread_ts=1707758148.919829&cid=C05LX9D6E07
PROPOSAL:

Tests

  • Verify that no errors appear in the JS console

Offline tests

QA Steps

  1. Build the iOS/Android app in production mode.
  2. Tap any area of the app using four fingers simultaneously.
  3. Verify that you see a modal screen with only the "Use Profiling" option; no other options should be present.
  4. Turn on the switcher
  5. Wait a few seconds and turn off the switcher
  6. You will see the 'Share' button appears
  7. Click on the button and share the trace.
  8. Check if the trace was shared
  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
2024-02-13.16.10.16.mp4
Android: mWeb Chrome
iOS: Native
RPReplay_Final1707834726.MP4
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop

@perunt
perunt marked this pull request as ready for review February 13, 2024 17:54
@perunt
perunt requested a review from a team as a code owner February 13, 2024 17:54
@melvin-bot
melvin-bot Bot requested review from srikarparsi and removed request for a team February 13, 2024 17:54
@melvin-bot

melvin-bot Bot commented Feb 13, 2024

Copy link
Copy Markdown

@srikarparsi 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]

@situchan

Copy link
Copy Markdown
Contributor

I can help if requires C+ review

@srikarparsi

Copy link
Copy Markdown
Contributor

Hi, yes that would be great thanks @situchan

@perunt
perunt marked this pull request as draft February 14, 2024 09:00

@situchan situchan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you marked as draft. Please request my review when ready. Thanks

@situchan

Copy link
Copy Markdown
Contributor

@situchan @srikarparsi typescript issues came from the main, so now, after the merge, it should be fine. Also, just to be sure that you double-checked this test step 3. Verify that you see a modal screen with only the "Use Profiling" option; no other options should be present. as we don't want to get the rest of the features in production

yes, I already confirmed in adhoc build

@perunt

perunt commented Feb 22, 2024

Copy link
Copy Markdown
Contributor Author

How to see Profile_trace_for_1.4.43-7.cpuprofile?
Edit: I traced using chrome://tracing/

@situchan, with https://www.speedscope.app/, you will see more details. Also, you would notice that anonymous function now has a trace
Screenshot 2024-02-22 at 17 04 23

@perunt

perunt commented Feb 22, 2024

Copy link
Copy Markdown
Contributor Author

@situchan @srikarparsi, if it tested well, when can we expect to get this merged?

@situchan

Copy link
Copy Markdown
Contributor

@situchan @srikarparsi, if it tested well, when can we expect to get this merged?

🟢 from me

@srikarparsi

Copy link
Copy Markdown
Contributor

Changes look good to me as well, waiting on confirmation about adding new modules to package.json before merging.

@srikarparsi

srikarparsi commented Feb 22, 2024 •

Copy link
Copy Markdown
Contributor

Hey @situchan and @hoangzinh, we have to get approval before adding libraries to package.json so I created two new issues for the two packages, react-native-share and react-native-release-profiler.

react-native-share - @situchan or @hoangzinh could you please help with the last three questions. You can leave a comment in the GH issue and I can update the body.

react-native-release-profiler - @situchan or @hoangzinh could you please help with the last four questions as well as the number of monthly downloads.

Thanks!

@perunt

perunt commented Feb 23, 2024

Copy link
Copy Markdown
Contributor Author

@srikarparsi I've added some comments to the issues above. I hope it will help push it forward

@srikarparsi

Copy link
Copy Markdown
Contributor

Hey! Could someone clarify why we're using react-native-share instead of the regular share from react native?

@perunt

perunt commented Feb 26, 2024

Copy link
Copy Markdown
Contributor Author

We're using react-native-share because the built-in React Native Share API doesn't support sharing files directly, only text and URLs. Plus, we need to share multiple files at once, which react-native-share handles well

@perunt

perunt commented Feb 27, 2024

Copy link
Copy Markdown
Contributor Author

@srikarparsi, any updates on this? Can I somehow push it forward?

@srikarparsi

srikarparsi commented Feb 28, 2024 •

Copy link
Copy Markdown
Contributor

Hey! Still waiting on these two issues (1, 2). I just bumped up the priority so they should hopefully be done soon.

@srikarparsi

Copy link
Copy Markdown
Contributor

Hey @perunt, have you had a chance to look at this comment here

@perunt

perunt commented Mar 6, 2024

Copy link
Copy Markdown
Contributor Author

@srikarparsi added my comments

urls: [`file://${sharePath}`, actualInfoFile],
};

await Share.open(shareOptions);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain what this line does? Does it just open the native file in the default browser?

@roryabraham roryabraham Mar 6, 2024 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, I see. This is opening the native share menu so you can do whatever you want with the file:

  • save it to the filesystem
  • email it
  • send it in slack
  • print it
  • whatever else

@srikarparsi

Copy link
Copy Markdown
Contributor

Awesome thanks @perunt! Also, do you think you could fix the conflicts whenever you get a chance. I think we should get approval for react-native-share and be able to merge by tomorrow.

@perunt

perunt commented Mar 7, 2024

Copy link
Copy Markdown
Contributor Author

@srikarparsi done.
Can I speed it up somehow?

@srikarparsi

Copy link
Copy Markdown
Contributor

Hey @perunt, we're still waiting on approval for react-native-share. We can merge as soon as that's done, hopefully today or tomorrow.

@srikarparsi srikarparsi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, also got approval for both libraries being added

@srikarparsi
srikarparsi merged commit 4c4e63f into Expensify:main Mar 11, 2024
@melvin-bot melvin-bot Bot added the Emergency label Mar 11, 2024
@melvin-bot

melvin-bot Bot commented Mar 11, 2024

Copy link
Copy Markdown

@srikarparsi looks like this was merged without a test passing. Please add a note explaining why this was done and remove the Emergency label if this is not an emergency.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/srikarparsi in version: 1.4.50-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@github-actions github-actions Bot mentioned this pull request Mar 11, 2024
49 tasks done
@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/luacmartins in version: 1.4.50-5 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

<TestToolMenu />
<View style={[StyleUtils.getTestToolsModalStyle(windowWidth)]}>
{isDevelopment && <TestToolMenu />}
<ProfilingToolMenu />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coming from #56787 checklist: The Profiler API isn’t supported on Safari and mWeb iOS, so we need to check for supported devices before rendering ProfilingToolMenu to prevent console warnings

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was added to Troubleshoot page also here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants