Skip to content

feat(core): experimental unstable versioned write for limited use case#854

Merged
dai-shi merged 41 commits intomainfrom
feat/experimental-version-object
Dec 28, 2021
Merged

feat(core): experimental unstable versioned write for limited use case#854
dai-shi merged 41 commits intomainfrom
feat/experimental-version-object

Conversation

@dai-shi
Copy link
Copy Markdown
Member

@dai-shi dai-shi commented Nov 29, 2021

I've been working on this for a few months now. It's since #687. Let's see how it goes. I will do some experiments and some patch releases towards this.

@vercel
Copy link
Copy Markdown

vercel Bot commented Nov 29, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/pmndrs/jotai/2pabms4dr23ebJ8oQbiBJfRNZez8
✅ Preview: https://jotai-git-feat-experimental-version-object-pmndrs.vercel.app

@codesandbox-ci
Copy link
Copy Markdown

codesandbox-ci Bot commented Nov 29, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 685ae4e:

Sandbox Source
React Configuration
React Typescript Configuration
React Browserify Configuration
React Snowpack Configuration
Next.js Configuration
Next.js with custom Babel config Configuration
React with custom Babel config Configuration

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Nov 29, 2021

Size Change: +1.59 kB (+4%)

Total Size: 43.4 kB

Filename Size Change
dist/esm/index.js 5.17 kB +723 B (+16%) ⚠️
dist/esm/utils.js 4.55 kB +56 B (+1%)
dist/index.js 5.96 kB +747 B (+14%) ⚠️
dist/utils.js 5.79 kB +67 B (+1%)
ℹ️ View Unchanged
Filename Size
dist/babel/plugin-debug-label.js 794 B
dist/babel/plugin-react-refresh.js 947 B
dist/babel/preset.js 1.21 kB
dist/devtools.js 1.74 kB
dist/esm/babel/plugin-debug-label.js 622 B
dist/esm/babel/plugin-react-refresh.js 763 B
dist/esm/babel/preset.js 1.01 kB
dist/esm/devtools.js 1.59 kB
dist/esm/immer.js 616 B
dist/esm/optics.js 661 B
dist/esm/query.js 1.25 kB
dist/esm/redux.js 251 B
dist/esm/urql.js 1.49 kB
dist/esm/valtio.js 526 B
dist/esm/xstate.js 1.13 kB
dist/esm/zustand.js 284 B
dist/immer.js 732 B
dist/optics.js 938 B
dist/query.js 1.36 kB
dist/redux.js 314 B
dist/urql.js 1.54 kB
dist/valtio.js 586 B
dist/xstate.js 1.19 kB
dist/zustand.js 344 B

compressed-size-action

Comment thread src/core/store.ts Outdated
export const COMMIT_ATOM = 'c'
export const SUBSCRIBE_ATOM = 's'
export const RESTORE_ATOMS = 'h'
export const VERSION_OBJECT = 'v'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd call this "SNAPSHOT"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it's just new Object().

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright 👍

@dai-shi
Copy link
Copy Markdown
Member Author

dai-shi commented Dec 11, 2021

Experimenting with https://github.com/dai-shi/will-this-react-global-state-work-in-concurrent-rendering

 jotai
   with useTransition
     ✓ test 1: updated properly with transition (4036 ms)
     ✓ test 2: no tearing with transition (27 ms)
     ✓ test 3: ability to interrupt render
     ✕ test 4: proper branching with transition (8684 ms)
   with intensive auto increment
     ✓ test 5: updated properly with auto increment (5236 ms)
     ✓ test 6: no tearing with auto increment (1 ms)
 jotai-versioned-write
   with useTransition
     ✓ test 1: updated properly with transition (2675 ms)
     ✓ test 2: no tearing with transition (29 ms)
     ✓ test 3: ability to interrupt render (1 ms)
     ✓ test 4: proper branching with transition (3481 ms)
   with intensive auto increment
     ✓ test 5: updated properly with auto increment (4024 ms)
     ✓ test 6: no tearing with auto increment (1 ms)

Works as hoped.

@dai-shi dai-shi marked this pull request as ready for review December 11, 2021 00:06
@dai-shi dai-shi added this to the v1.5.0 milestone Dec 11, 2021
@dai-shi
Copy link
Copy Markdown
Member Author

dai-shi commented Dec 12, 2021

https://github.com/krausest/js-framework-benchmark results

Default

Duration in milliseconds ± 95% confidence interval (Slowdown = Duration / Fastest)

image

unstable_enableVersionedWrite

Duration in milliseconds ± 95% confidence interval (Slowdown = Duration / Fastest)

image

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.

3 participants