Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shrink Atom and Reaction using a bitfield #3901

Merged
merged 1 commit into from
Jul 17, 2024

Conversation

peterm-canva
Copy link
Contributor

@peterm-canva peterm-canva commented Jul 8, 2024

Following on from #3880, use a bitfield to reduce the size of Atom and Reaction. Large apps can have 10s or 100s of thousands of these. Also further shrink ComputedValue by storing diffValue in the bitfield, because it's only ever 0 or 1.

Memory Savings

Class Bytes before Bytes after
ComputedValue 100 96
Atom 48 40
ObservableValue (inherits from Atom) 76 68
Reaction 72 56

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

  • N/A Added/updated unit tests
  • N/A Updated /docs. For new functionality, at least API.md should be updated
  • Verified that there is no significant performance drop (yarn mobx test:performance)

Copy link

changeset-bot bot commented Jul 8, 2024

🦋 Changeset detected

Latest commit: 281179f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
mobx Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mweststrate
Copy link
Member

Looking great again, thanks a lot!

@mweststrate mweststrate merged commit 5e711e0 into mobxjs:main Jul 17, 2024
1 check passed
@github-actions github-actions bot mentioned this pull request Jul 17, 2024
@wh1sp3r
Copy link

wh1sp3r commented Jul 23, 2024

My project stopped working after this update.
No error in output.

Will check exactly, what's happening

@urugator
Copy link
Collaborator

@wh1sp3r could be related to #3918

@spion
Copy link

spion commented Sep 27, 2024

I'll try to make a repro case this weekend and if it succeeds send a PR over to bump the version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants