rrweb icon indicating copy to clipboard operation
rrweb copied to clipboard

Improve mutation processing performance

Open eoghanmurray opened this issue 8 months ago • 3 comments

Refactor record time mutation processing to improve performance

  • smarter 'iteration' through the this.addedSet so that we start with nodes which already have the required nextId and parentId
  • take advantage of siblings sharing the same parent, so only do parent related calculations once instead of repeatedly for every child node
  • inline pushAdd (and getNextId) as we only need a single run over them

This solves pathological cases where nodes from the addedSet were pushed onto the secondary addList, possibly multiple times as pushAdd was called again each time the nextId/parentId requirements weren't met.

Previous efforts in this direction were

  • #1398 "traverse children in reverse order"
  • #1302 "optimize random shuffled addList"

Also related is #1277 "refactor recursive procedure to iterative" which we could also incorporate on top of this as it should provide orthogonal performance gains — in order to 'grasp the nettle' all at once in terms of possible breakage.

eoghanmurray avatar Feb 11 '25 21:02 eoghanmurray