rrweb icon indicating copy to clipboard operation
rrweb copied to clipboard

optimize isParentRemoved for large remove lists

Open mdellanoce opened this issue 1 year ago • 1 comments

Encountered a mutation that removes ~1400 nodes. Noticed a lot of the processing time was tied up in isParentRemoved, which repeatedly does an iterative search of the removes array. I added a map (nodeId => index in removes array) to speed up this process. See before/after images below:

Before: image

After: image

I didn't see a difference in the existing benchmarks, even though one of them involves removing a lot of nodes. The problem functionality shown in the profiles above involved scrolling through a large table that would dynamically remove/add pages of data as you scroll.

mdellanoce avatar Dec 06 '23 17:12 mdellanoce

🦋 Changeset detected

Latest commit: c68b3f26d7e58ca1dfe2c0061981f36fb4a470fe

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
rrweb Patch
rrweb-snapshot Patch
rrdom Patch
rrdom-nodejs Patch
rrweb-player Patch
@rrweb/types Patch
@rrweb/web-extension Patch
rrvideo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Dec 06 '23 17:12 changeset-bot[bot]