-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
Pre-filter and sort rules for 400% perf boost #246
Conversation
c9bc092
to
94f2fb0
Compare
Now that #245 is merged, I've rebased this branch. I'll try tidying up the code later this week. |
94f2fb0
to
7172aad
Compare
7172aad
to
9dc2d11
Compare
I've added another major optimization here: Instead of iterating over all the rules on every node (checking that the rule type matches the node type on each iteration), I pre-sort the rules by their The impact of these changes is huge. On the current The code could still use some cleanup, but I'm thrilled with the improvement. For comparison, this takes |
@amilajack OK, I've done some refactoring to tidy up the code on this branch and improve Flow coverage. I hope it's reasonably clear and well-organized now. Please let me know if there are any changes you'd like to see! |
Awesome! This is a huge improvement to this project! Thank you so much 🎉. I'll add this to the 3.3.0 release as well. |
Closes #193
Currently, the
Lint()
function loops through all 4361 rules on every node. The cost of all that looping really adds up! For most projects, most of those rules are irrelevant because they only fail for very old or esoteric browsers. In the project I used to test this branch, the browser list isand only 1679 of the rules potentially fail. For a project that only supports modern browsers (no IE11), the relevant set of rules would be much smaller.
This PR filters the set of rules based on the targeted browser list, removing the need to iterate through irrelevant rules on every node. It does that filtering only once per browser list. This change reduces the time it takes to run
compat/compat
against my test project from ~5.5s to ~2.5s. 🚀I've marked this as WIP because the code here is very messy, so please take it as a proof of concept. If you like this change, let me know and I'll tidy it up!