Open MichalBryxi opened 7 months ago
Note: this PR is based on this discussion and at the moment it should fail as we're in known non-performant situation. This is merely to track the situation and see when we get to a better place.
Possible fix here (gives only 2.3-3x regression, instead of 100x) (inspired by https://github.com/vuejs/vue/blob/bed04a77e575d6c4c1d903f60087dca874f7213e/src/core/observer/array.ts#L17)
addon/src/-private/array.ts
return new Proxy(clone, {
get(target, prop /*, _receiver */) {
let index = convertToInt(prop);
+ if (prop === 'splice') {
+ return (...args) => {
+ try {
+ return new TrackedArray(target.splice(...args));
+ } finally {
+ setValue(self.#collection, null);
+ }
+ };
}
Oh wow, with your change I'm getting for 10M items:
Before (best case) = 2953ms After (worst case) = 7.89ms
So if i can potato with math, it's 374.2x improvement 🤯
Crux
new TrackedArray().splice()
.Performance tests
splice
.Other tests
TODOs
Relates to: #405