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

Slowness actionTrackingMiddleware #440

Open
hersentino opened this issue Mar 18, 2022 · 3 comments
Open

Slowness actionTrackingMiddleware #440

hersentino opened this issue Mar 18, 2022 · 3 comments
Labels

Comments

@hersentino
Copy link

hersentino commented Mar 18, 2022

Hello,

I made an example branch (https://github.com/hersentino/mobx-keystone-issue/tree/middleware) which shows that actionTrackingMiddleware has some slowness even if onStart/onEnd do nothing. Just calling it takes about 25ms. 50 ms if the data passed in parameter to the modelAction are big.
The problem is if I call modelAction inside modelAction n times it can significantly impact the global performance.

Do you have an idea explaining these durations ?

Thanks :)

@xaviergonz
Copy link
Owner

is the repo public? I get a 404

@hersentino
Copy link
Author

I'm sorry, I made a mistake, I've just edited the url

@xaviergonz
Copy link
Owner

it takes longer because you are measuring the detachment of the old big tree as part of the instantiation of the new small tree

if you add

    this.setMainModel(undefined);

after each setMain model you will see the following results instead:

With big data
time of instanciation with fromGrpc without middleware : 789.8999999910593 ms
time of instanciation with fromGrpc with middleware : 854.8999999910593 ms
time took by the middleware 65 ms

With small data
time of instanciation with fromGrpc without middleware : 0.29999999701976776 ms
time of instanciation with fromGrpc with middleware : 0.8999999910593033 ms
time took by the middleware 0.5999999940395355 ms

@xaviergonz xaviergonz added the 🤷‍♂️ more info required More info is required label Mar 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants