-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[$250] [Due for payment 2025-07-14] Use indexed object structure for OnyxCache #64950
Copy link
Copy link
Closed
Labels
Awaiting PaymentAuto-added when associated PR is deployed to productionAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.Something is broken. Auto assigns a BugZero manager.DailyKSv2KSv2ExternalAdded to denote the issue can be worked on by a contributorAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributorsApply this label when an issue is open to proposals by contributors
Metadata
Metadata
Labels
Awaiting PaymentAuto-added when associated PR is deployed to productionAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.Something is broken. Auto assigns a BugZero manager.DailyKSv2KSv2ExternalAdded to denote the issue can be worked on by a contributorAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributorsApply this label when an issue is open to proposals by contributors
Type
Fields
Give feedbackNo fields configured for issues without a type.
Projects
Status
Done
Coming from here
Background
react-native-onyx is using its internal cache mechanism to get value from cache while first connection to Onyx is being made through useOnyx so the cached value can be returned immediately.
Problem
When useOnyx requests collection data from cache while the first connection to Onyx is being made, the implementation loops through all cached keys to find matching items, which causes response times to degrade linearly with cache size, which prevents large accounts from achieving acceptable performance in multiple flows of the app.
Solution
Change the shape of the Onyx cache to store collections as indexed objects instead of flat key-value pairs. When requesting collection data, the useOnyx should directly access the pre-organized collection object instead of iterating through thousands of keys. This transforms collection access from O(n) complexity to O(1), delivering instant retrieval regardless of cache size.
Some numbers from account with 42k cached Onyx keys:
Thanks to that useOnyx times go down as well - on opening Expense chat total time dropped from ~650ms to ~170ms
Issue Owner
Current Issue Owner: @Upwork Automation - Do Not Edit