Fix performance regression in fm_renumber#828
Merged
Conversation
stevenslack
approved these changes
Mar 1, 2022
Contributor
stevenslack
left a comment
There was a problem hiding this comment.
I pulled down the branch and added the sample code to reproduce the issue, while it is still slow, it is a slight improvement. The largest timeout I received on this branch was 770ms while on the main branch I received some timeouts upwards of 12229ms!!
I don't see anything in the code which is a blocker, but reading the code is a bit nuanced as there are no docblocks or comments in this JavaScript. Comments with some context could help speed up a refactor, but that may be out of scope for this fix.
🌶
Contributor
|
@mboynes The comments are very helpful! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The performance regression from 1.3 → 1.4 was due to this traversal:
Since the script knows which elements it changed, this update stores a reference to each changed element to avoid the later DOM traversal.
While this fixes the regression from 1.3 → 1.4,
fm_renumber()is still very slow at scale because of all the DOM traversal. A significant refactor is in order.Resolves #827
For posterity, here's some sample code to produce a very slow experience adding and sorting...