-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[masking] Optimize full snapshot serialization performance #1338
Conversation
|
I'm concerned that this introduces a bit too much (incremental) complexity by adding a separate method of doing the check. Would you consider the following strategy?
That might be a bit slower than your method, but would be faster for the regex case and would mean we'd have the masking logic all in one place. |
I've embodied what I've described above in #1349 Would you be able to compare it from a performance perspective in the same way you did your one? My take turned out to be not as elegant as I hoped as it exposed that |
… the DOM (#1349) * masking performance: avoid the repeated calls to `closest` when recursing through the DOM - needsMask===true means that an ancestor has tested positively for masking, and so this node and all descendents should be masked - needsMask===false means that no ancestors have tested positively for masking, we should check each node encountered - needsMask===undefined means that we don't know whether ancestors are masked or not (e.g. after a mutation) and should look up the tree * Add tests including an explicit characterData mutation tests * Further performance improvement: avoid calls to `el.matches` when on a leaf node, e.g. a `<br/>` --------- Authored-by: eoghanmurray <eoghan@getthere.ie> Based on initial PR #1338 by Alexey Babik <alexey.babik@noibu.com>
#1349 is merged so closing this one |
… the DOM (rrweb-io#1349) * masking performance: avoid the repeated calls to `closest` when recursing through the DOM - needsMask===true means that an ancestor has tested positively for masking, and so this node and all descendents should be masked - needsMask===false means that no ancestors have tested positively for masking, we should check each node encountered - needsMask===undefined means that we don't know whether ancestors are masked or not (e.g. after a mutation) and should look up the tree * Add tests including an explicit characterData mutation tests * Further performance improvement: avoid calls to `el.matches` when on a leaf node, e.g. a `<br/>` --------- Authored-by: eoghanmurray <eoghan@getthere.ie> Based on initial PR rrweb-io#1338 by Alexey Babik <alexey.babik@noibu.com>
Implementation for #1337
Within the snapshot serialization, I refined the method by which rrweb determines if text should be masked. Presently, for every individual text node during recursion, the closest method is invoked to ascertain if the node is a descendant of an element marked for masking. I modified this by passing the masking flag directly as a parameter to the recursion function, thereby eliminating superfluous lookups.