Skip to content

[HOLD for payment 2024-05-29] LOW: [$250] [Performance] Only import the preferred locale and load the other language dynamically if needed #41893

Closed

Description

@mountiny

Coming from Slack

Problem:

Currently, both translations for emoji in English (EN) and Spanish (ES) are imported during app initialization. Additionally, we create large objects of EmojiTrie for both languages. The idea is to import and build EmojiTrie only for the currently selected language.

Solution:

  1. During app initialization, we check the preferred language and import only that translation file.
  2. We create an EmojiTrie only for that selected language.
  3. If the user changes the language, we will dynamically import the new translation file and create a new Trie object at that time.

In most cases, users only use one language, so by implementing this change, we can significantly reduce memory consumption and the time needed for creating large EmojiTrie objects.

Some numbers measured on web:

Before dynamic imports:
EmojiTrie Create time -> 66ms
we import and create EmojiTrie for all languages (for now we have en and es)

After dynamic imports:
EmojiTrie Create time -> 17ms
we import and create EmojiTrie only for one selected language

Another gain is that we don't keep expensive unused EmojiTrie in the memory

Note

On mobiles this adds up to ~300-400ms for the whole tree so each first chat visit is delayed by at least this much, definitely worth cutting it down

cc @rinej @adhorodyski

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~015852e4cf6c6066f2
  • Upwork Job ID: 1788527552271863808
  • Last Price Increase: 2024-05-09
Issue OwnerCurrent Issue Owner: @
Issue OwnerCurrent Issue Owner: @stephanieelliott

Activity

  1. self-assigned this
    on May 9, 2024
  2. melvin-bot commented on May 9, 2024

    @melvin-bot

    Triggered auto assignment to @stephanieelliott (NewFeature), see https://stackoverflowteams.com/c/expensify/questions/14418#:~:text=BugZero%20process%20steps%20for%20feature%20requests for more details. Please add this Feature request to a GH project, as outlined in the SO.

  3. rinej commented on May 9, 2024

    @rinej
    Contributor

    Here is Tomek from callstack, I'd like to work on that

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on May 9, 2024
  5. melvin-bot commented on May 9, 2024

    @melvin-bot
  6. changed the title [-][Performance] Only import the preferred locale and load the other language dynamically if needed[/-] [+][$250] [Performance] Only import the preferred locale and load the other language dynamically if needed[/+] on May 9, 2024
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on May 9, 2024
  8. 20 remaining items

  9. stephanieelliott commented on May 17, 2024

    @stephanieelliott
    Contributor

    #41097 deployed to staging on May 15 🎉

  10. stephanieelliott commented on May 21, 2024

    @stephanieelliott
    Contributor

    PR is still on staging, I am going to move this to Weekly in the meantime

  11. stephanieelliott commented on May 29, 2024

    @stephanieelliott
    Contributor

    This was deployed to prod on May 22, will be ready for payment on May 29

  12. changed the title [-]LOW: [$250] [Performance] Only import the preferred locale and load the other language dynamically if needed[/-] [+][HOLD for payment 2024-05-29] LOW: [$250] [Performance] Only import the preferred locale and load the other language dynamically if needed[/+] on May 29, 2024
  13. mountiny commented on May 29, 2024

    @mountiny
    ContributorAuthor

    $250 to @shubham1206agra i dont think there is need for regression test here as its performance improvement

  14. melvin-bot commented on May 29, 2024

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@stephanieelliott)

    • I have verified the correct assignees and roles are listed above and updated the neccesary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1788527552271863808/hired)
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  15. stephanieelliott commented on May 30, 2024

    @stephanieelliott
    Contributor

    Hey @shubham1206agra I extended the offer to you in Upwork, can you accept it when you get a chance? https://www.upwork.com/nx/wm/offer/102533807

  16. shubham1206agra commented on May 31, 2024

    @shubham1206agra
    Contributor
  17. stephanieelliott commented on Jun 1, 2024

    @stephanieelliott
    Contributor

    All paid, thanks @shubham1206agra!

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionExternalAdded to denote the issue can be worked on by a contributorNewFeatureSomething to build that is a new item.WeeklyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions