Skip to content

[HOLD for payment 2024-04-05] [HOLD for payment 2024-03-26] [Performance] Use Intl API from Hermes where possible #38447

Closed

Description

@mountiny

Coming from Slack cc @hurali97 please comment so I can assign you

### Problem
We have Intl polyfills in the codebase to provide for the missing JS APIs. While that’s not a bad thing, we can take advantage of Hermes supported Intl APIs and avoid polyfilling them. If we don’t do it, we add ~500 ms to the App Startup time on android on a heavy account.

Solution

Hermes has a list of Intl supported APIs and we can take advantage of them. On native platforms, we can remove the Intl APIs that are supported by Hermes and only polyfill the ones that are currently not supported/ worked on by Hermes.
We can safely remove the following polyfills from localize/index.native.ts:

  • @formatjs/intl-getcanonicallocales/polyfill
  • @formatjs/intl-datetimeformat
  • @formatjs/intl-numberformat
  • @formatjs/intl-pluralrules/polyfill

Below is how things will look like after the removal:

import polyfillListFormat from './polyfillListFormat';
import type IntlPolyfill from './types';

/**
 * Polyfill the Intl API, always performed for native devices.
 */
const intlPolyfill: IntlPolyfill = () => {
    // Native devices require extra polyfills which are
    // not yet implemented in hermes.
    // see support: https://hermesengine.dev/docs/intl/

    require('@formatjs/intl-locale/polyfill');

    polyfillListFormat();
};

export default intlPolyfill; 

With this, we only polyfill the APIs that are not supported/ worked on by hermes. Doing so, we save ~500 ms in the App Startup. Before and After Hermes trace screenshots are attached in the PR description.
Here’s the PR with the implementation.

Activity

  1. added
    Daily
    Bug
    on Mar 16, 2024
  2. self-assigned this
    on Mar 16, 2024
  3. melvin-bot commented on Mar 16, 2024

    @melvin-bot

    Triggered auto assignment to @abekkala (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

  4. assigned and unassigned on Mar 16, 2024
  5. melvin-bot commented on Mar 18, 2024

    @melvin-bot

    ⚠️ Looks like this issue was linked to a Deploy Blocker here

    If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

    If a regression has occurred and you are the assigned CM follow the instructions here.

    If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

  6. added
    Reviewing
    Weekly
    Awaiting Payment
    and removed
    Daily
    Weekly
    on Mar 19, 2024
  7. 2 remaining items

  8. melvin-bot commented on Mar 19, 2024

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  9. melvin-bot commented on Mar 19, 2024

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.54-4 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2024-03-26. 🎊

  10. melvin-bot commented on Mar 19, 2024

    @melvin-bot

    BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

    • [@rlinoz] The PR that introduced the bug has been identified. Link to the PR:
    • [@rlinoz] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
    • [@rlinoz] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
    • [@rlinoz] Determine if we should create a regression test for this bug.
    • [@rlinoz] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
    • [@abekkala] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
  11. abekkala commented on Mar 20, 2024

    @abekkala
    Contributor

    PAYMENT SUMMARY FOR MAR 26

    • Fix: @hurali97 - Callstack - no Upwork payment
    • PR Review: @rlinoz - Internal - no payment 😉

    @rlinoz do you think this one needs a regression test? otherwise, I can close this one out on Mar 26 after the PR regression period ends.

  12. rlinoz commented on Mar 20, 2024

    @rlinoz
    Contributor

    This got reverted actually, so let's keep it open.

    But I don't think it needs a regression test

  13. abekkala commented on Mar 22, 2024

    @abekkala
    Contributor

    PAYMENT SUMMARY FOR MAR 26

    • Fix: @hurali97 - Callstack - no Upwork payment
    • PR Review: @rlinoz - Internal - no payment 😉

    No regression test needed - this can be closed on Mar 26 after waiting period has ended

  14. slafortune commented on Mar 26, 2024

    @slafortune
    Contributor

    Just taking the action here - @abekkala has it all summarized 👍

  15. added
    Weekly
    and removed
    Weekly
    on Mar 29, 2024
  16. changed the title [-][HOLD for payment 2024-03-26] [Performance] Use Intl API from Hermes where possible[/-] [+][HOLD for payment 2024-04-05] [HOLD for payment 2024-03-26] [Performance] Use Intl API from Hermes where possible[/+] on Mar 29, 2024
  17. melvin-bot commented on Mar 29, 2024

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.57-5 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2024-04-05. 🎊

  18. melvin-bot commented on Mar 29, 2024

    @melvin-bot

    BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

    • [@rlinoz] The PR that introduced the bug has been identified. Link to the PR:
    • [@rlinoz] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
    • [@rlinoz] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
    • [@rlinoz] Determine if we should create a regression test for this bug.
    • [@rlinoz] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
    • [@slafortune / @abekkala] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentBugWeekly

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions