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

Stale-props-free useSelector #43

Closed
wants to merge 2 commits into from
Closed

Conversation

dai-shi
Copy link
Owner

@dai-shi dai-shi commented Jan 20, 2020

reduxjs/react-redux#1505

Trying the same for reactive-react-redux. The code is very different because rrr is based on state context.

@dai-shi
Copy link
Owner Author

dai-shi commented Jan 20, 2020

react-redux-benchmarks result
v4.5.0-alpha.0 repesents 3971f79.

Running benchmark deeptree
  react-redux type-version: useSelector-rrr-4.4.0
    Checking max FPS... (30 seconds)
    Running trace...    (30 seconds)
  react-redux type-version: useSelector-rrr-4.5.0-alpha.0
    Checking max FPS... (30 seconds)
    Running trace...    (30 seconds)

Results for benchmark deeptree:
┌───────────────────────────────┬─────────┬──────────────┬───────────┬───────────┬──────────┬─────────────────────────────────────────────────────────────────────────────────────┐
│ Type-Version                  │ Avg FPS │ Render       │ Scripting │ Rendering │ Painting │ FPS Values                                                                          │
│                               │         │ (Mount, Avg) │           │           │          │                                                                                     │
├───────────────────────────────┼─────────┼──────────────┼───────────┼───────────┼──────────┼─────────────────────────────────────────────────────────────────────────────────────┤
│ useSelector-rrr-4.4.0         │ 41.74   │ 69.3, 0.7    │ 10005.69  │ 10503.45  │ 5747.53  │ 55,54,52,53,54,52,55,54,53,54,52,53,44,33,36,33,31,32,31,23,24,21,24,22,22          │
├───────────────────────────────┼─────────┼──────────────┼───────────┼───────────┼──────────┼─────────────────────────────────────────────────────────────────────────────────────┤
│ useSelector-rrr-4.5.0-alpha.0 │ 33.26   │ 160.1, 1.3   │ 15211.86  │ 8210.17   │ 3719.64  │ 34,40,39,38,35,36,40,37,38,39,37,36,41,40,38,36,42,40,31,26,24,25,24,25,18,23,22,22 │
└───────────────────────────────┴─────────┴──────────────┴───────────┴───────────┴──────────┴─────────────────────────────────────────────────────────────────────────────────────┘
Running benchmark deeptree-nested
  react-redux type-version: useSelector-rrr-4.4.0
    Checking max FPS... (30 seconds)
    Running trace...    (30 seconds)
  react-redux type-version: useSelector-rrr-4.5.0-alpha.0
    Checking max FPS... (30 seconds)
    Running trace...    (30 seconds)

Results for benchmark deeptree-nested:
┌───────────────────────────────┬─────────┬──────────────┬───────────┬───────────┬──────────┬──────────────────────────────────────────────────────────────────────────────────┐
│ Type-Version                  │ Avg FPS │ Render       │ Scripting │ Rendering │ Painting │ FPS Values                                                                       │
│                               │         │ (Mount, Avg) │           │           │          │                                                                                  │
├───────────────────────────────┼─────────┼──────────────┼───────────┼───────────┼──────────┼──────────────────────────────────────────────────────────────────────────────────┤
│ useSelector-rrr-4.4.0         │ 52.21   │ 125.8, 1.5   │ 5698.01   │ 4526.01   │ 1944.99  │ 58,60,57,60,57,58,59,55,58,56,57,55,58,57,54,55,50,47,48,47,46,47,42,44,43,25,25 │
├───────────────────────────────┼─────────┼──────────────┼───────────┼───────────┼──────────┼──────────────────────────────────────────────────────────────────────────────────┤
│ useSelector-rrr-4.5.0-alpha.0 │ 48.19   │ 121.5, 2.2   │ 7939.38   │ 4527.65   │ 1872.63  │ 58,57,51,36,56,59,51,54,53,54,52,55,52,53,52,51,41,39,40,44,40,43,41,39,42,42    │
└───────────────────────────────┴─────────┴──────────────┴───────────┴───────────┴──────────┴──────────────────────────────────────────────────────────────────────────────────┘
Running benchmark forms
  react-redux type-version: useSelector-rrr-4.4.0
    Checking max FPS... (30 seconds)
    Running trace...    (30 seconds)
  react-redux type-version: useSelector-rrr-4.5.0-alpha.0
    Checking max FPS... (30 seconds)
    Running trace...    (30 seconds)

Results for benchmark forms:
┌───────────────────────────────┬─────────┬──────────────┬───────────┬───────────┬──────────┬──────────────────────────────────────────────────────────────────────────────────┐
│ Type-Version                  │ Avg FPS │ Render       │ Scripting │ Rendering │ Painting │ FPS Values                                                                       │
│                               │         │ (Mount, Avg) │           │           │          │                                                                                  │
├───────────────────────────────┼─────────┼──────────────┼───────────┼───────────┼──────────┼──────────────────────────────────────────────────────────────────────────────────┤
│ useSelector-rrr-4.4.0         │ 54.88   │ 1273.2, 0.4  │ 5916.72   │ 1063.69   │ 3050.52  │ 56,55,41,54,55,57,54,56,54,55,58,57,52,57,56,55,52,57,55,52,57,52,56,57,56,56    │
├───────────────────────────────┼─────────┼──────────────┼───────────┼───────────┼──────────┼──────────────────────────────────────────────────────────────────────────────────┤
│ useSelector-rrr-4.5.0-alpha.0 │ 54.52   │ 1195.5, 0.5  │ 5992.53   │ 1017.80   │ 2831.66  │ 57,55,58,57,58,57,58,55,57,53,56,57,55,46,53,44,56,50,54,57,58,48,57,50,52,56,56 │
└───────────────────────────────┴─────────┴──────────────┴───────────┴───────────┴──────────┴──────────────────────────────────────────────────────────────────────────────────┘
Running benchmark stockticker
  react-redux type-version: useSelector-rrr-4.4.0
    Checking max FPS... (30 seconds)
    Running trace...    (30 seconds)
  react-redux type-version: useSelector-rrr-4.5.0-alpha.0
    Checking max FPS... (30 seconds)
    Running trace...    (30 seconds)

Results for benchmark stockticker:
┌───────────────────────────────┬─────────┬──────────────┬───────────┬───────────┬──────────┬──────────────────────────────────────────────────────────────────────────────────┐
│ Type-Version                  │ Avg FPS │ Render       │ Scripting │ Rendering │ Painting │ FPS Values                                                                       │
│                               │         │ (Mount, Avg) │           │           │          │                                                                                  │
├───────────────────────────────┼─────────┼──────────────┼───────────┼───────────┼──────────┼──────────────────────────────────────────────────────────────────────────────────┤
│ useSelector-rrr-4.4.0         │ 55.68   │ 170.4, 2.0   │ 11873.95  │ 11867.26  │ 4103.98  │ 55,59,42,59,58,56,54,59,54,57,53,55,51,60,58,53,54,55,58,54,56,55,53,53          │
├───────────────────────────────┼─────────┼──────────────┼───────────┼───────────┼──────────┼──────────────────────────────────────────────────────────────────────────────────┤
│ useSelector-rrr-4.5.0-alpha.0 │ 36.26   │ 195.2, 3.7   │ 16096.92  │ 9012.24   │ 2764.84  │ 38,47,49,48,40,38,35,41,31,34,29,39,40,37,38,29,39,34,27,34,35,32,28,30,35,34,34 │
└───────────────────────────────┴─────────┴──────────────┴───────────┴───────────┴──────────┴──────────────────────────────────────────────────────────────────────────────────┘
Running benchmark tree-view
  react-redux type-version: useSelector-rrr-4.4.0
    Checking max FPS... (30 seconds)
    Running trace...    (30 seconds)
  react-redux type-version: useSelector-rrr-4.5.0-alpha.0
    Checking max FPS... (30 seconds)
    Running trace...    (30 seconds)

Results for benchmark tree-view:
┌───────────────────────────────┬─────────┬──────────────┬───────────┬───────────┬──────────┬──────────────────────────────────────────────────────────────────────────────────┐
│ Type-Version                  │ Avg FPS │ Render       │ Scripting │ Rendering │ Painting │ FPS Values                                                                       │
│                               │         │ (Mount, Avg) │           │           │          │                                                                                  │
├───────────────────────────────┼─────────┼──────────────┼───────────┼───────────┼──────────┼──────────────────────────────────────────────────────────────────────────────────┤
│ useSelector-rrr-4.4.0         │ 49.48   │ 541.2, 3.0   │ 6028.66   │ 9471.73   │ 683.69   │ 42,52,45,40,51,44,52,51,48,43,55,48,49,46,51,52,55,53,46,51,56,52,47,48,54,49,49 │
├───────────────────────────────┼─────────┼──────────────┼───────────┼───────────┼──────────┼──────────────────────────────────────────────────────────────────────────────────┤
│ useSelector-rrr-4.5.0-alpha.0 │ 19.10   │ 574.9, 71.1  │ 24439.80  │ 3129.67   │ 204.70   │ 36,19,20,26,20,18,20,17,19,20,18,9,21,19,13,18,19,17,15,16,19,21,17,19,21,13,13  │
└───────────────────────────────┴─────────┴──────────────┴───────────┴───────────┴──────────┴──────────────────────────────────────────────────────────────────────────────────┘
Running benchmark twitter-lite
  react-redux type-version: useSelector-rrr-4.4.0
    Checking max FPS... (30 seconds)
    Running trace...    (30 seconds)
  react-redux type-version: useSelector-rrr-4.5.0-alpha.0
    Checking max FPS... (30 seconds)
    Running trace...    (30 seconds)
TypeError: Cannot read property 'actualTime' of undefined

Why is the last one failed?

@dai-shi
Copy link
Owner Author

dai-shi commented Jan 20, 2020

js-framework-benchmark result

2020-01-21 6 32 21

@dai-shi
Copy link
Owner Author

dai-shi commented Jan 20, 2020

useReducer needs to read state always from context. fixed in cbfad09 with spec.

@dai-shi
Copy link
Owner Author

dai-shi commented Jan 20, 2020

Hmmm, it doesn't work. Oh, context is not updated yet when calling update... 🤔

My observation is that reducer can't read the future context.

@dai-shi
Copy link
Owner Author

dai-shi commented Jan 21, 2020

Okay, I conclude this approach doesn't work with changedBits=0. React will never trigger re-renders...

I will run benchmarks with reduxjs/react-redux#1505.

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.

1 participant