Skip to content

[Due for payment 2025-07-14] [$250] Improve the subscribeToKey efficiency in Onyx #64774

Closed

Description

@mountiny

Coming from this proposal

Problem

Onyx.connect uses subscribeToKey to subscribe to keys, but it performs an O(n) iteration over all Onyx keys - even for exact key matches.
This inefficiency becomes a major bottleneck on screens with many Onyx connections (e.g., screens with lists having per-item subscriptions). When entering expense chat on an account with 40k Onyx keys, it spends 900ms looping through them multiple times.

Solution

Optimize subscribeToKey by distinguishing between:

  • Non-collection keys - use direct lookup instead of iterating through all keys
  • Collection keys - use current iteration logic

Tested on iOS simulator with 40k keys:

  • App launch: isKeyMatch total time dropped from 770ms to 330ms
  • Expense report screen: isKeyMatch dropped from 900ms to 35ms
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021937284236503470296
  • Upwork Job ID: 1937284236503470296
  • Last Price Increase: 2025-06-23
Issue OwnerCurrent Issue Owner: @adelekennedy

Activity

  1. added
    External
    Daily
    Bug
    on Jun 23, 2025
  2. changed the title [-]Improve the subscribeToKey efficiency in Onyx[/-] [+][$250] Improve the subscribeToKey efficiency in Onyx[/+] on Jun 23, 2025
  3. melvin-bot commented on Jun 23, 2025

    @melvin-bot
  4. added
    Help Wanted
    on Jun 23, 2025
  5. melvin-bot commented on Jun 23, 2025

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @ikevin127 (External)

  6. melvin-bot commented on Jun 23, 2025

    @melvin-bot

    Triggered auto assignment to @adelekennedy (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  7. removed
    Help Wanted
    on Jun 23, 2025
  8. 18 remaining items

  9. changed the title [-][$250] Improve the subscribeToKey efficiency in Onyx[/-] [+][Due for payment 2025-07-14] [$250] Improve the subscribeToKey efficiency in Onyx[/+] on Jul 7, 2025
  10. melvin-bot commented on Jul 7, 2025

    @melvin-bot

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

  11. removed
    Reviewing
    on Jul 7, 2025
  12. melvin-bot commented on Jul 7, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.76-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 2025-07-14. 🎊

    For reference, here are some details about the assignees on this issue:

    • @TMisiukiewicz does not require payment (Contractor)
    • @s77rt requires payment through NewDot Manual Requests
    • @ikevin127 requires payment through NewDot Manual Requests
  13. melvin-bot commented on Jul 7, 2025

    @melvin-bot

    @s77rt / @ikevin127 @adelekennedy The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  14. mountiny commented on Jul 7, 2025

    @mountiny
    ContributorAuthor

    $250 to @ikevin127

  15. moved this from CRITICAL to Done in [#whatsnext] #qualityon Jul 7, 2025
  16. ikevin127 commented on Jul 10, 2025

    @ikevin127
    Contributor

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other: Performance improvement

    Where bug was reported:

    • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
    • 2b. Reported on staging (eg. found during regression or PR testing)
    • 2d. Reported on a PR
    • 2z. Other: Performance improvement

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • [Contributor] 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: N/A - Performance improvement

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source 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: N/A

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    Regression Test Proposal

    Not needed as the PR for this issue was a performance improvement task.

  17. added
    Daily
    and removed
    Weekly
    on Jul 13, 2025
  18. melvin-bot commented on Jul 14, 2025

    @melvin-bot

    Payment Summary

    Upwork Job

    • Contributor: @TMisiukiewicz is from an agency-contributor and not due payment
    • Reviewer: @s77rt owed $250 via NewDot
    • Reviewer: @ikevin127 owed $250 via NewDot

    BugZero Checklist (@adelekennedy)

    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1937284236503470296/hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  19. JmillsExpensify commented on Jul 14, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @ikevin127

  20. adelekennedy commented on Jul 14, 2025

    @adelekennedy
    Contributor

    Payment Summary

    Contributor+: @ikevin127 due $250 via NewDot

  21. s77rt commented on Jul 14, 2025

    @s77rt
    Member

    I'm not due payment here ^

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

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions