dai-shi / proxy-memoize

Intuitive magical memoization library with Proxy and WeakMap
http://proxy-memoize.js.org/
MIT License
719 stars 16 forks source link

memoized function with large state takes a very long time. #68

Closed gnawjaren closed 1 year ago

gnawjaren commented 1 year ago

I have a very large state - and a selector which calculates values on this state. (touching many properties) I tried to memoize this selector with proxy-memoize, but it takes a very long time. (~1000ms, vs ~1ms without memoize/with reselect) Is this expected ? (high count of properties to compare ?)

Is there anything I can do about it ?

Here is a sandbox with a very simplified example. I included plain (no memoization), proxy-memoize, and reselect versions.

https://codesandbox.io/s/intelligent-pine-8i9lom?file=/src/index.test.js

This is the timing for the various versions:

tests

This is output of the Chrome Profiler:

profile

Thank you very much for this project, I like this approach.

dai-shi commented 1 year ago

Hi, thanks for reporting. We had some issues about performance drop before, but this looks like a new case.

We need to dig into it. Not sure if there's an easy way to fix. Is anyone interested? Maybe @Aslemammad ?

Aslemammad commented 1 year ago

Can I be assigned to this one?

dai-shi commented 1 year ago

@gnawjaren Would you like to try #72? https://ci.codesandbox.io/status/dai-shi/proxy-memoize/pr/72 ☝️ Find "Local Install Instructions"

gnawjaren commented 1 year ago

I can confirm, it's blazing fast now. Thanks a lot.

Aslemammad commented 1 year ago

I'm happy we could acheive such results, Thank you for letting us know.

On Sat, 6 May 2023, 14:31 Jan Wagner, @.***> wrote:

I can confirm, it's blazing fast now. Thanks a lot.

— Reply to this email directly, view it on GitHub https://github.com/dai-shi/proxy-memoize/issues/68#issuecomment-1537117262, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJBMICH3OKSOQHT72Q5HVK3XEYVQZANCNFSM6AAAAAAXOCGDKY . You are receiving this because you were assigned.Message ID: @.***>

dai-shi commented 1 year ago

Published: https://www.npmjs.com/package/proxy-memoize/v/2.0.4