-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
Coming from https://expensify.slack.com/archives/C05LX9D6E07/p1751978498770109
Background
Our app uses a derived value system where values are computed from entire collections. Even when the computation itself is fast (often <5ms), we spend significantly more time (hundreds of milliseconds) inside Onyx internals when writing these large derived values to storage.
Problem
Onyx.set isn’t optimized for large objects like derived values. It performs a deep equality check against the cached value and recursively removes nulls, both of which become performance bottlenecks as object size grows.
Solution
Add an options parameter to Onyx.set with two flags:
- skipCacheCheck: skips the deep equality check
- skipNullRemoval: skips pruning null values
For derived values, we fully control their lifecycle and recompute them when any dependency changes - so we know the value is new and don’t need a deep comparison. Also, null may be a legitimate result of the computation, so pruning it is unnecessary. Skipping these two checks significantly improves performance when working with large objects.
Comparison made on a derived value we should have merged soon in this PR: #65247
Before: 165ms
After: <5ms
Issue Owner
Current Issue Owner: @VictoriaExpensifyMetadata
Metadata
Labels
Type
Projects
Status