8000 feat(typescript-estree): cache project glob resolution by bradzacher · Pull Request #6367 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

feat(typescript-estree): cache project glob resolution #6367

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

Merged
merged 6 commits into from
Jan 31, 2023

Conversation

bradzacher
Copy link
Member
@bradzacher bradzacher commented Jan 23, 2023

PR Checklist

Overview

Whilst reviewing #6084 I realised we could save some time in the parser by caching the parserOptions.project glob resolution results. So I spent a bit of time throwing this together.

I tested this locally and it saved a little bit of time (~1 second) because our glob is so small (we use packages/*/tsconfig.json - which only matches 15 folders.
Though it's still eye-opening to see that the tiny globbing for our repo adds up to an entire second.

I double checked these results by taking a CPU profile before and after:

$ TSESTREE_SINGLE_RUN=true node --cpu-prof ./node_modules/.bin/eslint .

Then I inspected the profiles on https://speedscope.app
For reference - the profiles: PROFILES.zip

Before change:
image

After change:
image

I would expect that this change should show a large perf improvement in the following cases:

  • single-star glob that matches many directories (eg packages/*/tsconfig.json on something the size of babel's packages folder or bigger)
  • lots of globs matching all over the place (eg ['foo/*/tsconfig.json', 'bar/*/tsconfig.json', 'baz/*/tsconfig.json', ...])
  • really any case with double star globs

@bradzacher bradzacher added the performance Issues regarding performance label Jan 23, 2023
@typescript-eslint
Copy link
Contributor

Thanks for the PR, @bradzacher!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

@nx-cloud
Copy link
nx-cloud bot commented Jan 23, 2023

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 5e71d4b. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 47 targets

Sent with 💌 from NxCloud.

@netlify
Copy link
netlify bot commented Jan 23, 2023

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 5e71d4b
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/63d97ae88ea4330008327daa
😎 Deploy Preview https://deploy-preview-6367--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@bradzacher bradzacher force-pushed the cache-glob-resolution branch from 245edda to 9226a45 Compare January 23, 2023 12:32
@codecov
Copy link
codecov bot commented Jan 23, 2023

Codecov Report

Merging #6367 (6ec13e0) into main (5bf7f7f) will increase coverage by 0.01%.
The diff coverage is 93.15%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6367      +/-   ##
==========================================
+ Coverage   91.38%   91.40%   +0.01%     
==========================================
  Files         368      370       +2     
  Lines       12608    12652      +44     
  Branches     3713     3723      +10     
==========================================
+ Hits        11522    11564      +42     
- Misses        770      771       +1     
- Partials      316      317       +1     
Flag Coverage Δ
unittest 91.40% <93.15%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
.../src/create-program/getWatchProgramsForProjects.ts 79.08% <ø> (+0.68%) ⬆️
...ges/typescript-estree/src/create-program/shared.ts 80.43% <50.00%> (-2.90%) ⬇️
...pescript-estree/src/parseSettings/ExpiringCache.ts 95.23% <95.23%> (ø)
...ipt-estree/src/parseSettings/resolveProjectList.ts 95.55% <95.55%> (ø)
...pt-estree/src/parseSettings/createParseSettings.ts 97.50% <100.00%> (+0.67%) ⬆️

Copy link
Member
@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

Love to see the perf improvements!

@JoshuaKGoldberg JoshuaKGoldberg added the awaiting response Issues waiting for a reply from the OP or another party label Jan 25, 2023
@bradzacher bradzacher removed the awaiting response Issues waiting for a reply from the OP or another party label Jan 30, 2023
Copy link
Member
@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

🔥 :shipit:

(once build fix)

@JoshuaKGoldberg JoshuaKGoldberg merged commit afae837 into main Jan 31, 2023
@JoshuaKGoldberg JoshuaKGoldberg deleted the cache-glob-resolution branch January 31, 2023 20:47
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
performance Issues regarding performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0