modify immer metrics to scan 5000 index #1
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
this is super interesting and appreciate all the work. i am seeing slow behavior with immer 9 and freeze.
i'm not necessarily trying to merge anything, but just wanted to open this PR to show some benchmark changes that highlight some interesting results
in immerjs/immer#1152 it's mentioned that
i'm not familiar enough with the internals of immer to know guess what is causing things to slowdown, but from my testing, there are cases were
freeze: false
significantly worsens performance.from my testing, performance gets worse when "scanning" an array.
please let me know if i've misunderstood the code or the benchmarks.
if i'm understanding these benchmarks correctly, there is an array of 10000 items, and then we call various actions/operations.
add -> push
remove -> splice
updateItem -> find
concat -> concat
in the original benchmarks
the
i
which is only 0, so thefind
andsplice
don't do much. in this PR, i switchedi
to 5000 (so find the element withitem.id === action.payload.id
andsplice(5000, 1)
) and things get much worse, especially withfreeze: false
.i'm aware
freeze
is the default and highly recommended for immutability and safety, but it also seems like it is basically required for performance reasons.i've attached my benchmarks below.