Skip to content
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

jest-resolve 18% performance optimization #8183

Merged
merged 2 commits into from
Mar 21, 2019

Conversation

scotthovestadt
Copy link
Contributor

@scotthovestadt scotthovestadt commented Mar 21, 2019

Summary

jest-resolve is called heavily by jest-resolve-dependencies when finding related tests. Benchmarking the simple change from Object to Map for the internal cache shows an 18% improvement in the total run time of dependencyResolver.resolveInverse for a test data set of 300k~ files, although obviously the performance characteristics are going to vary depending on the data set.

At Facebook, this PR means when I run just Jest to look at my changed files and run the appropriate tests, it boots up 2 seconds faster.

Test plan

  • All tests pass. New tests not appropriate for this simple change.
  • Tested manually.
  • Benchmarked to ensure performance improvement.

@codecov-io
Copy link

codecov-io commented Mar 21, 2019

Codecov Report

Merging #8183 into master will decrease coverage by 0.01%.
The diff coverage is 40.74%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #8183      +/-   ##
=========================================
- Coverage   62.32%   62.3%   -0.02%     
=========================================
  Files         265     265              
  Lines       10469   10477       +8     
  Branches     2545    2545              
=========================================
+ Hits         6525    6528       +3     
- Misses       3361    3366       +5     
  Partials      583     583
Impacted Files Coverage Δ
packages/jest-resolve/src/index.ts 40.44% <40.74%> (-0.19%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f809c79...3cff75c. Read the comment docs.

Copy link
Collaborator

@thymikee thymikee left a comment

Choose a reason for hiding this comment

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

Great idea to use the map internally :)

@scotthovestadt scotthovestadt changed the title jest-resolve performance optimizations for hot spot jest-resolve 18% performance optimization Mar 21, 2019
@SimenB
Copy link
Member

SimenB commented Mar 21, 2019

At Facebook, this PR means when I run just Jest to look at my changed files and run the appropriate tests, it boots up 2 seconds faster.

😮

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

awesome!

(aaaaand changelog :D)

Copy link
Member

@cpojer cpojer left a comment

Choose a reason for hiding this comment

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

Nice! I'm so glad you are looking into this. fyi if you can improve jest-resolve's performance, you may be able to significantly speed up the runtime of all tests. It's been my dream to work on this but never got around to it :D

@scotthovestadt scotthovestadt merged commit 800e6fb into jestjs:master Mar 21, 2019
@rubennorte
Copy link
Contributor

This is great @scotthovestadt! I investigated this some time ago when I landed a similar change in the haste map (#6960) but back then it didn't seem to make a significant difference. I'm glad it makes now! :D

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants