-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Improve performance of SearchSource.findMatchingTests by 15% #8184
Improve performance of SearchSource.findMatchingTests by 15% #8184
Conversation
Codecov Report
@@ Coverage Diff @@
## master #8184 +/- ##
==========================================
- Coverage 62.32% 62.32% -0.01%
==========================================
Files 265 265
Lines 10469 10465 -4
Branches 2545 2541 -4
==========================================
- Hits 6525 6522 -3
Misses 3361 3361
+ Partials 583 582 -1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! I thought the code looked weird when I migrated this to TS, makes sense to use an array instead here
(changelog)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet! Left some minor comments. Missing changelog
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
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. |
Summary
This PR is a 15% performance improvement for
SearchSource.findMatchingTests
. I benchmarked a test data set of 300k files at 975ms~ with the current code. The same search pattern now executes in 830ms~.At Facebook, this means that for the common use case of triggering
jest MyFileName
, Jest will launch >100ms faster. Sometimes you have to take the small wins. :)I optimized this by looking for inefficiencies in code that is called for every file. In this case:
Object.keys
for thestats
object every time. Not efficient.I refactored away the issues by adapting the data structures to better fit the way they are being used. Since our stat filters are optional and we want to iterate them, they make more sense as an array. I maintained full type safety.
Test plan