leoasis / redux-immutable-state-invariant

Redux middleware that detects mutations between and outside redux dispatches. For development use only.
MIT License
937 stars 37 forks source link

Slow on a big state tree partially managed by immutable.js #20

Closed ocolot closed 7 years ago

ocolot commented 8 years ago

I happen to have 8 reducers, where 6 of them are immutable objects. I use redux-immutable-state-invariant to make sure the remaining 2 reducers respect immutability too.

As you can see below, the Chrome profile reports that 50% of the CPU time is used by redux-immutable-state-invariant. This made my interface unresponsive.

screen shot 2016-08-30 at 19 18 52

May you should add a warning in the 'how to use' section of the repository?

leoasis commented 8 years ago

Ah that's interesting, I think that's actually because the middleware is going through all the inner properties of the immutable structures, which can have a lot of info. Maybe we could add some kind of ignore function in the initialization to be able to bypass mutation detection in some paths of the reducers.

ocolot commented 8 years ago

It seems a good option!

On Tue, Sep 20, 2016, 04:49 Leonardo Garcia Crespo notifications@github.com wrote:

Ah that's interesting, I think that's actually because the middleware is going through all the inner properties of the immutable structures, which can have a lot of info. Maybe we could add some kind of ignore function in the initialization to be able to bypass mutation detection in some paths of the reducers.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/leoasis/redux-immutable-state-invariant/issues/20#issuecomment-248187540, or mute the thread https://github.com/notifications/unsubscribe-auth/AB4oKB75JuJ_dx5X4hZc9YxcfHXJjGOXks5qr0nSgaJpZM4JwxYu .

Olivier Colot

Web entrepreneur, Musician +32 486 80 10 70 - Co-creation studio http://www.cocreation.studio/?utm_source=email-signature&utm_medium=email&utm_campaign=Email%20signature%20clicks

joncursi commented 7 years ago

Same issue. I use ImmutableJS to manage my Redux state on a very big React Native app. The simulator gets twice as slow when this package is running and checking the actions on the fly in dev.

leoasis commented 7 years ago

@joncursi are you using ImmutableJS for all your data? If so, then you don't need this library. It's main objective is to show errors whenever you attempt to mutate regular JS objects or arrays in your state, but with ImmutableJS, you cannot do that by definition.

On the other hand, if you have mixed types of state (regular objects and arrays and also immutable objects and arrays), then maybe a solution like ignoring some branches of the state may be good for this (PRs welcome if this is the case)

leoasis commented 7 years ago

Version 2.0.0 has been released and now supports two options that can help solve this problem: isImmutable and ignore. Check the Readme to know how to use them. Closing this issue since that should solve it.

Feel free to reopen if this is not the case, or the solutions provided are not enough.