Description
📝 Provide a description of the improvement
This is a performance graph for undoing removal of the "long (semantic)" content in http://localhost:8125/ckeditor5/tests/manual/performance/setdata.html.
As you can see Position#parent
is the most expensive thing here. We could not find ways to make it much faster by changing its implementation.
However, then I noticed when it's used and after looking at implementation of #nodeAfter
, #nodeBefore
, and #textNode
I realised that we're executing the #parent
getter many times per each of these prop getters calls.
You can find the current implementation of these functions here: https://github.com/ckeditor/ckeditor5-engine/blob/ff045099fdea35c2af90a6da3d1a546845aeb3ea/src/model/position.js#L199-L242
Let's see if we can save 50%+ of time by rewriting them into uglier, but more optimal forms :).
If you'd like to see this improvement implemented, add a 👍 reaction to this post.
Activity
Reinmar commentedon Apr 8, 2020
After playing with the code for 15 minutes I got down to this:
From 1165ms to 378ms :).
The entire undo action got down from 3.2s to 2.2s.
PR's coming!
Reinmar commentedon Apr 8, 2020
Loading "long (semantic)" content into the editor:
Merge pull request #1837 from ckeditor/i/6579
Merge pull request #1837 from ckeditor/i/6579