Skip to content
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

Fix a replay issue where the 500ms timeout was being hit #1320

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

eoghanmurray
Copy link
Contributor

@eoghanmurray eoghanmurray commented Oct 9, 2023

  • 3.7K nodes being inserted, with ~200 <tr>s as the root nodes making up the resolveTrees array
  • each table row was dependent on the next, resulting in cascading failures; 19K instances of repopulation of queue due to nextNotInDOM, and an additional cascading 350K repopulation of queue due to missing parent nodes as algorithm attempted to continue over children

 - 3.7K nodes being inserted, with ~200 <tr>s as the root nodes making up the `resolveTrees`
 - each table row was dependent on the next, resulting in cascading failures; 19K repopulation of queue due to `nextNotInDOM`, and an additional cascading 350K repopulation of queue due to missing parent nodes
@changeset-bot
Copy link

changeset-bot bot commented Oct 9, 2023

🦋 Changeset detected

Latest commit: 2525e47

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

const rootTree = putIntoMap(mutation, null);
if (rootNexts.has(mutation.node.id)) {
// some existing tree can't be inserted until this one is (nextNotInDOM check)
queueNodeTrees.unshift(rootTree);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Word of caution here - shift is O(n) which makes this operation O(n^2) now. Since this seems to be a hot path, you might be better off using a different data structure here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the assumption here was that queueNodeTrees will be small in comparison to the tree data structure within each one. At any rate, the queueToResolveTrees function is there to put some organisation on the nodes in order to forestall the pathological cases elsewhere (the appendNode and the fact that appendNode can fail and put things back on the queue which causes the whole while (queue.length) { bit to brute force again and again)
So I think this is a minor concern; it could be replaced by a doubly linked list but my assumption would be that it's not a hot path.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable, I just wanted to highlight it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants