rintoj / statex

StateX is a state management library for modern web applications with unidirectional data flow and immutable uni-state (just like redux)
MIT License
68 stars 18 forks source link

How to Use Production Version of Seamless-Immutable #8

Closed thatcort closed 6 years ago

thatcort commented 6 years ago

The seamless-immutable library is slowing my application. It has a production version that should be much faster (at the expense of safety). I've tried building my Angular application using the -prod flag, but it's still using the development version of seamless. I believe to use the production version one needs to import it explicitly: https://github.com/rtfeldman/seamless-immutable/issues/50

Can we change statex to use the production version of seamless at the appropriate times or add a configuration to not use seamless?

rintoj commented 6 years ago

@thatcort, not using seamless immutable is not an option. Library at its core uses functions provided by seamless immutable to perform actions such as deep merge of objects. Also keeping the object immutable helps frameworks (both angular and react) to use shallow diff on objects to detect changes. That is the original idea behind the immutable app state.

Said that, I can look at the option to integrate production version of seamless.

By the way would be able to give the numbers of how much your application was slowed down?

thatcort commented 6 years ago

Sure, here are a couple screenshots of a performance profile of my app. The first is just the top-level view, showing seamless accounting for many of the major performance hits. But the situation is worse than this, because when I expand the top 'GC' and 'Gecko' items, most of that time is also from seamless as (second screenshot).

Finally, seamless necessitates a number of expensive array duplications where they shouldn't be required. For example, given an immutable array it makes the new arrays returned by methods such as map and filter immutable too, so if I need to perform mutating methods on those results, then I need to make a copy even though the original contents won't be modified.

Thanks for looking into this!

screen shot 2018-01-25 at 4 09 42 pm screen shot 2018-01-25 at 4 12 10 pm
rintoj commented 6 years ago

Hi @thatcort,

Updated to 1.1.4 to use production version of seamless-immutable when process.env.NODE_ENV=production. Please check and let me know how this works for you.