Performance: cache browserSelection by resolved browserslist #199
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.
Stylelint is very slow in our projects (1m10s for 1300 files, 8m 3200 files) when using https://github.com/RJWadley/stylelint-no-unsupported-browser-features. After some research, we isolated the issue to doiuse.
I see @cmrn added
missingSupportCache
in #182 — however, whenoptions.browsers
is not provided (the default), CSS file path is used as the cache key, so the cache is not actually shared between files. The benchmark linked master...RJWadley:doiuse:benchmark-2 explictly passsesbrowsers
, so it likely mismeasures the perf impact.browserslist
had a similar caching issue, which we just fixed in v4.24.4 with browserslist#862 browserslist#864, so the config resolution should be fine now.Building upon these enhancements, we can simplify caching: browserslist caches config resolution on its side, and doiuse only caches
compileBrowserSupport
.This change speeds up stylelint 8x in our case, from 1m10s to 9s. @cmrn I see you have access to more benchmarks, maybe you could check them as well?