-
Notifications
You must be signed in to change notification settings - Fork 23
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
Slowness with big model #432
Comments
is your app going to mutate the models? |
Btw, the times of time of setting are greatly reduced if you don't use the redux middleware. With redux middleware: Without redux middleware: |
Ok, I just tried that option and it is actually slower (1.4s vs 1.2s) due to the extra type checking involved to automatically detect the type. |
That being said I just published v0.67.1, which should make model creation around 25% faster when used with mobx 6. (In my case your example went down from 1000ms to around 750ms) |
Thanks for the quick responses ! I've just try without the reduxtools and with the fromSnapshot, like that :
end the results are much quicker ! time of instanciation with fromGrpc : 289 ms
The problem is that I want to have models because I have modelAction and if I understand frozen are made for immutable data and the objects are not keystone models. |
for that test to be accurate you'll need to either inject $modelType to your whole snapshot object tree or to make sure all model properties that reference models use a tProp and then use fromSnapshot(MainModel, data); if you don't do that then you will just get a "simple" object without actions/etc.
Yes, that's not a good case for frozen then. |
yep I did try and you're right I can't access to the modelAction.
So I did try to modify my fromGrpc functions to inject the $modelType to the data and then use fromSnapshot(data) and the time of instantiation is pretty much the same (about 800ms), you can find a reproducible example in the branch "fromSnapshot" (https://github.com/hersentino/mobx-keystone-issue/tree/fromSnapshot). Is it expected to have similar time with fromSnapshot ? |
I don't think fromSnapshot would help much, it basically does the same thing you do manually by creating sub-models. the best way I could think of improving the speed is to either: |
I'm trying the b solution and I start to have some good result, but i'm struggling to create reference with DataModel, can you confirm that is possible ? Also I'm a chrome user so didn't notice yet but the example that I provide upside is about 2 times slower with firefox (without any extension, v98.0.2). Result with chrome : Result with firefox : |
Hello,
I use mobx-keystone in a project where i'm managing big amount of data that I get from api call.
The model that I receive are not mobx-keystone snapshot but the api models match my mobx-keystone models, except for the $modeltype. When I instance my mobx-keystone models from the api data, it can be very long like more than 1 second.
I've seen your fix on v0.67.0 version but in my case instantiations are still long with big models.
I've made a reproducible example here: https://github.com/hersentino/mobx-keystone-issue
In this example you can find a big amount of data (that i really get from an api).
I change all tProp by prop in models to save type checking time.
Are I doing something wrong ?
Thanks
The text was updated successfully, but these errors were encountered: