Shrink Atom and Reaction using a bitfield #3901
Merged
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.
Following on from #3880, use a bitfield to reduce the size of
Atom
andReaction
. Large apps can have 10s or 100s of thousands of these. Also further shrinkComputedValue
by storingdiffValue
in the bitfield, because it's only ever0
or1
.Memory Savings
ComputedValue
Atom
ObservableValue
(inherits fromAtom
)Reaction
Name Changes
Note this PR changes the names of some members of the above classes to get around the problem mentioned here: #3880 (comment). If these are part of a documented, stable public API then we will need to find another solution.
Soaking Time
We discussed here #3880 (comment) that we should let the previous changes to
ComputedValue
soak for a bit to flush out any issues. We have been shipping those changes for a few weeks in production now and haven't seen any problems yet.Code change checklist
/docs
. For new functionality, at leastAPI.md
should be updatedyarn mobx test:performance
)