Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@cmrn
Copy link
Contributor

@cmrn cmrn commented Mar 6, 2024

This PR improves the performance of doiuse in two ways, making it run 3-10 times faster:

  1. Cache the result of BrowserSelection.missingSupport(), since compiling the list of missing features is an expensive operation. This improves performance when the postcss plugin is run over multiple CSS files, like when linting an entire codebase.
  2. Refactor Detector to flatten and normalise all feature checks during initialization, rather than using expensive Object.entries operations to parse the rules at every node in the syntax tree.

Benchmarks (from master...RJWadley:doiuse:benchmark-2):

run time diff
Before changes 5.3s -
Cache missingSupport 4.8s -0.5s
Refactor of Detector 2.2s -3.1s
After both changes 1.7s -3.6s

Other benchmarks:

benchmark before after
postcss/benchmark 233ms 44ms
stylelint's benchmark 6s 1.5s
private repo: ~300 CSS files 50s 5s
private repo: ~8300 CSS files 8m 50s 1m 30s

@cmrn cmrn changed the title Performance: Cache missingSupport and refactor Detector Performance: Cache missingSupport and refactor Detector Mar 6, 2024
Copy link
Collaborator

@clshortfuse clshortfuse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. It all looks good. Just left some comments in case some improvements can be made.

@cmrn
Copy link
Contributor Author

cmrn commented Jun 17, 2024

hi @clshortfuse, just a friendly bump on this PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants