Skip to content

fix(eslint-plugin): [no-misused-promises] perf: avoid getting types of variables/functions if the annotated type is obviously not a function #9656

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 3 commits into from
Jul 29, 2024

Conversation

bradzacher
Copy link
Member

Overview

I sat down for a few minutes to try perf profiling our codebase (writeup coming slowly in #6366) to look for some obvious improvements.

One thing that immediately stood out was that almost 10% of our lint run was spent in no-misused-promises' checkVariableDeclaration function. We can fix this easily by doing a quick syntactic check to filter out cases of (a) not-annotated variables and (b) annotated types that can never be function types.

This completely removes the function from the left-heavy cpu profile flame graph.

It ultimately doesn't change the lint run performance, however, because types are lazily calculated - so it has only shifted the workload to another rule -- but if we can do this enough we can shift that needle.

…f variables/functions if the annotated type is obviously not a function
@bradzacher bradzacher added the performance Issues regarding performance label Jul 29, 2024
@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.

Copy link

netlify bot commented Jul 29, 2024

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 37b85c7
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/66a6ec39dca98900085ba626
😎 Deploy Preview https://deploy-preview-9656--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (🟢 up 1 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 90 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

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

Copy link

nx-cloud bot commented Jul 29, 2024

☁️ Nx Cloud Report

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

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

Copy link

codecov bot commented Jul 29, 2024

Codecov Report

Attention: Patch coverage is 94.11765% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.05%. Comparing base (f38728c) to head (7e3ff4a).
Report is 1 commits behind head on v8.

Current head 7e3ff4a differs from pull request most recent head 37b85c7

Please upload reports for the commit 37b85c7 to get more accurate results.

Additional details and impacted files
@@           Coverage Diff           @@
##               v8    #9656   +/-   ##
=======================================
  Coverage   88.04%   88.05%           
=======================================
  Files         402      402           
  Lines       13639    13655   +16     
  Branches     3959     3966    +7     
=======================================
+ Hits        12009    12024   +15     
  Misses       1322     1322           
- Partials      308      309    +1     
Flag Coverage Δ
unittest 88.05% <94.11%> (+<0.01%) ⬆️

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

Files Coverage Δ
...ges/eslint-plugin/src/rules/no-misused-promises.ts 97.18% <94.11%> (-0.28%) ⬇️

Copy link
Member

Choose a reason for hiding this comment

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

(merge shenanigan)

Copy link
Member Author

Choose a reason for hiding this comment

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

nah i added this cos I was running from the root with node --cpu-prof --max-old-space-size=10000 ./node_modules/.bin/eslint . and our lint run was matching reporting on files in these two folders.

the / should make eslint ignore the entire folder without globbing etc

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.

Awesome! ⚡

@JoshuaKGoldberg JoshuaKGoldberg added the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Jul 29, 2024
@bradzacher bradzacher merged commit 37c10e8 into v8 Jul 29, 2024
57 of 58 checks passed
@bradzacher bradzacher deleted the bjz/no-misused-promises-perf-tweak branch July 29, 2024 07:18
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge performance Issues regarding performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants