improve perf delaying conversion to immutable objects #794
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A few performance tweaks to help ease some of the issues with #791...
Looking in the Performance tab of devtools, we can see that most of the tab is spent in re-rendering the toolbar buttons. Because when the selection changes, they need to recalculate whether they should be "active" or not.
Which (on my machine), when selecting the "large document" amount of text in the "rich text" example is taking 38 seconds. 😱
Most of the time is spent re-rendering the mark buttons...
But there is also a decent chunk spent recalculating the block buttons...
All in all the largest amount of time is spent in...
This PR changes the way lots of the
get*
andget*AtRange
methods work to delay converting to Immutable.js objects until after iterating, since it's a lot faster to use.map
,.filter
, etc. with regular arrays when possible than with immutable objects.After all of the changes, the benchmarks show a pretty decent increase for many things...
And now re-running the same performance analysis shows that the total time for the same re-rendering is now ~8 seconds instead of 38. And now the biggest time sink is actually in the block buttons, because the mark buttons have been significantly sped up...
Still more work to be done, but a pretty big win for very little work.