perf: Skip a write to storage when nothing is actually changing #92
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@marcaaron
Details
PR3. Of the changes planned here: #88 (comment)
Update set to check with cache and skip writing to storage. Cache reflects what's already on disc, if we have the exact value in cache it means it didn't change and we don't need to make a write
Quite a few times we're trying to "overwrite" something that didn't change, the most notable one is modal where I would see 19 consecutive calls to write false and on top of that the value in storage is already false
If cache has a value it's always the most recent up to date value
So when we try to write a value, but we have a cached key and the exact same value in cache we can skip the write
Related Issues
Expensify/App#2667
Automated Tests
Covered by existing unit tests
Linked PRs
Benchmarks
Hash the benchmarks were performed on: Expensify/App@b2582f3
Legend
Onyx.get
is called with thecurrencyList
key. Used as a reference point as usually it's the point on Android where the "last long" call happens.Android Before
Android After
iOS Before
iOS After