-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
caching parse results for rebuilds #3145
Comments
See #2640, #2746... (I would also add that it's also a common misassumption to believe that the bottleneck is the parsing while it's actually the rendering - like 30%/60% or even more of overall time (depending on actual code complexity and features used)... So ask yourself if some 10sec -> 7sec improvement would be worth your efforts all). |
@seven-phases-max thanks for the pointers... is there anyway to cache rendering results or partial rendering results? |
Probably... Though I suspect checking if partial rendering results are affected will take the same time (simply because it's the same thing as the rendering. There's no independently compiled units within a single Less->CSS session so anything may be affected by everything). In general I would not do anything at all w/o performing a detailed benchmark first, as you never know where the real bottleneck might be (and it's almost always turns out to be found in some contra-intuitive place... for example try to disable some unused/not-so-important features - e.g. sourcemap output and see if there're significant changes in compilation time). |
@lohfu Actually, in 3.x, I did add some additional caching of the imported files in the import manager IIRC, but I'm not certain it would have any effect with gulp.watch. It's really to prevent unnecessary duplicate XHR calls when the same file is imported twice from separate files within the same project. With Less, I don't think you can really cache any parts of the evaluation, because the evaluation of any Less node depends on its context, and that context would change based on how the tree changes. And if, say, what's updated in your parsing is a In short: as @seven-phases-max indicated, caching is not the answer. If you want to speed up performance, then you have to look at optimizing evaluation paths. There are some proposals currently that SHOULD improve evaluation speed by removing leaky variables from Less, which would effectively mean that mixin / DR calls wouldn't have to be re-evaluated over and over if the same vars are passed in.... BUT that's more a side-benefit of simplifying the language, and a) it's not clear how much performance would be gained, and b) it's of course entirely dependent on your specific Having spent time in the codebase for some time now (although some have spent more time there than me, like @lukeapage and probably even @seven-phases-max), my suspicion is that there are a few potential targets for improving Less performance:
The key to all of this is that you need to have accurate benchmarks to compare code changes. In all honesty, I haven't the faintest how one would go about that. At some point I added the performance-now library for benchmarking, but that will only give you a rough idea of speed on your particular system at a particular moment in time. I'm not sure how you would do A/B testing to see if a change you made made any difference whatsoever. I think if you figure that out, then actually testing other changes would be a lot easier. And maybe there is some additional caching that can be done, I don't know. You're welcome to look! And if you find areas of potential improvement, by all means make a PR that demos how you tracked that improvement. Hope that helps. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I am currently working on a project with quite a substantial amount of less. i am using
gulp.watch
to run rebuilds.i was hoping the rebuilds would be faster than the initial build, but they take exactly as long. is there a way to cache parsing results between rebuilds? optimally i would like to be able to store the cache to a file as well so the cache can be read and used for the initial builds as well.
i am willing to dig through code and try implement some kind of solution myself but would appreciate some pointers in the right direction. For example, should the FileManager or ImportManager try to cache parsing results?
The text was updated successfully, but these errors were encountered: