manaflair / redux-batch

Enhance your Redux store to support batched actions
174 stars 12 forks source link

Extremely poor performance in certain cases #10

Closed nealoke closed 6 years ago

nealoke commented 6 years ago

Hi, I've come across an issue in my application where I use this project to batch around 160 actions at once, but for some reason it is causing my UI to freeze as it takes around 1.5s to dispatch it.

Things I checked as best as i can that are not causing the UI freezing:

Pseudo code

const actions = [
    {
        type: 'RECEIVE_ACCOUNT_DAY_STAT',
        payload: { ... }
    },

    // x 160
];

dispatch(actions); // This takes around 1.5s
arcanis commented 6 years ago

I don't see any reason why redux-batch would have such a perf impact by itself. It doesn't do anything crazy other than a map (or some recursion in case you have arrays within arrays, but that's probably quite rare) :/

arcanis commented 6 years ago

If you want to debug this on your side, dispatchRecurse is the only part of the code with a non-constant complexity. I suggest adding performance.now() calls here and see what happens.

linonetwo commented 6 years ago

I think the problem may be the cost of the UI rerender. I used to update a huge table, and in a single rerender, it freezes. Using immutable solves it.