-
Notifications
You must be signed in to change notification settings - Fork 32
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
Performance of "extends" regex #36
Comments
Wow, that's pretty extreme. Out of curiosity, how large is the CSJS template string you are using? I haven't really done any benchmarking yet so I'm sure I there's lots of room for optimization. The current implementation is very simple. I can probably make it a lot faster, I just hadn't run into a problem myself yet. |
I have about 15 calls to I'm trying to improve regex. This seems to work much, much faster: It parses some whitespace differently but so far it seems to be working in the same way. Didn't have time to get into actual code or test if it works with every |
I think there's some easy (and possibly really big) performance wins to be had by doing a bit of simple lexical analysis (i.e. splitting the CSS into tokens). That should allow for simpler regex. But first I'm going to set up some benchmarking tooling: #12 |
Thank you so much for you contribution of your faster regex! I couldn't find any cases where it wasn't working and all tests were passing, so I've merged it in and released it as I've created an issue for general performance optimization here: #39 |
@mkazlauskas, I'm working on some benchmarking tools right now, would you mind posting some of the rules you were working with when you had the severe performance issues? Thanks! |
@scott113341 Sorry I can't provide anything specific since I replaced csjs with css modules. I wish I stayed with csjs though, much more flexible. It should be fairly easy to reproduce - I don't think I used anything special as my css skills are pretty amateur, just a good number of |
Ok, no worries. Thanks @mkazlauskas, we'll make sure to test |
Current way of parsing extends is way too slow. It takes up most of my (small) app's load time. Here is a screenshot from Chrome's Timeline. Looks like it takes 95%+ of the whole script eval.
Wrapping regex parse in
reduced page load time by about 1.3 seconds. I tried removing every single
extends
from my scss, it doesn't really matter, the pattern is just slow by itself.The text was updated successfully, but these errors were encountered: