-
-
Notifications
You must be signed in to change notification settings - Fork 852
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
Immer takes a long time to update the data. #867
Comments
At a quick glance it looks indeed that the shallowCopy used during finalisation could be more efficient in case the proto is Object, feel free to submit a PR if interested to explore further! I don't think the other call to it can be changed, if there are getters / setters present. Not fully sure :). |
@MinJieLiu try this, it can reduce some running time. setAutoFreeze(false); |
@blinkcat |
Should we make |
The current immer copies data even with object references from draft, so shallowCopy optimization seems to work better than my thoughts. It would be even better if we could delay prepareCopy until the actual write. |
I submitted the PR for this. I don't know if it's a valid way of immer. If this PR can't be merged, feel free to close it. |
you can check this online example, we can see immer is more fast than before. |
@fantasticsoul I don't mind seeing immer reimplemented, but I do mind using our issue tracker as a billboard. I'll leave the comment here up, as is the unique selling point is perf, that might be relevant, but I will remove most of the other comments. |
I patched my installation of immer with the key lines from #941 and I got a decrease from 70ms to 3ms in my redux reducer in a typical workload. #941 definitely seems like a useful PR, which would make the perf optimization optional, just like |
Poking my head in with two thoughts:
edit Note from https://www.reddit.com/r/javascript/comments/108bnwo/i_made_a_typescript_library_similar_to_immer_but/ :
|
🎉 This issue has been resolved in version 10.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🐛 Bug Report
Immer takes a long time to update the data.
Link to repro
To Reproduce
Chrome console:
Observed behavior
I checked the source code, the problem is in
shallowCopy
。If you useObject.assign
instead, there is no performance problemTime-consuming code:
Expected behavior
Time shouldn't be so long
Environment
We only accept bug reports against the latest Immer version.
setUseProxies(true)
setUseProxies(false)
(ES5 only)The text was updated successfully, but these errors were encountered: