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 Owner
Current Issue Owner: @adelekennedy
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:
Tested on iOS simulator with 40k keys:
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @adelekennedy