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

feat(typescript-estree): experimental option to cache type checking APIs #6426

Conversation

JoshuaKGoldberg
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg commented Feb 5, 2023

PR Checklist

Overview

Applies a thin memoization layer on top of getSymbolAtLocation and getTypeAtLocation.

hyperfine measurements are not very promising:

Package v6 Memoizing shortcut API Memoizing type checker
eslint-plugin 21.467 s ± 0.096 s 21.465 s ± 0.121 s 26.675 s ± 0.096 s
typescript-estree 11.755 s ± 0.052 s 11.983 s ± 0.113 s 12.128 s ± 0.045 s

I'm betting I'll want to add caching around the native type checker (checker.getContextualType) too.

I'll probably want to add an EXPERIMENTAL_ option so we can put this in v6 and get easier real world testing.

Co-authored-by: @bradzacher

@JoshuaKGoldberg JoshuaKGoldberg added this to the 6.0.0 milestone Feb 5, 2023
@typescript-eslint
Copy link
Contributor

Thanks for the PR, @JoshuaKGoldberg!

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 Feb 5, 2023

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 7c564ea. 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


🟥 Failed Commands
Node 18 - nx test typescript-estree
✅ Successfully ran 45 targets

Sent with 💌 from NxCloud.

@JoshuaKGoldberg JoshuaKGoldberg changed the title perf(typescript-estree): cache type checking APIs feat(typescript-estree): cache type checking APIs Feb 5, 2023
@codecov
Copy link

codecov bot commented Feb 5, 2023

Codecov Report

Merging #6426 (3a8b206) into v6 (c036fe3) will decrease coverage by 0.09%.
The diff coverage is 0.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##               v6    #6426      +/-   ##
==========================================
- Coverage   87.46%   87.38%   -0.09%     
==========================================
  Files         374      374              
  Lines       12879    12891      +12     
  Branches     3811     3813       +2     
==========================================
  Hits        11265    11265              
- Misses       1229     1241      +12     
  Partials      385      385              
Flag Coverage Δ
unittest 87.38% <0.00%> (-0.09%) ⬇️

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

Impacted Files Coverage Δ
...ages/typescript-estree/src/createParserServices.ts 26.31% <0.00%> (-45.12%) ⬇️
...pt-estree/src/parseSettings/createParseSettings.ts 85.71% <ø> (ø)

@bradzacher
Copy link
Member

hyperfine measurements are not very promising:

What's the command you used to grab the hyperfine measurement?
I've been raw-dogging the entire codebase lint run via ./node_modules/.bin/eslint . (to work around yarn and ensure i run eslint directly).

Do we have a bigger type-aware codebase we can test on?
Maybe we can just turn on every single rule in our codebase for the test run to increase the possibility of cache hits (I know we're fairly conservative in our type-aware linting ATM).

@JoshuaKGoldberg
Copy link
Member Author

JoshuaKGoldberg commented Feb 14, 2023

yarn lint --skip-nx-cache - it's deep in the edit history. I do want to do more thorough checking, including on the codebase as a whole. And there might be more type checker APIs that should be cached. I like the turning on every rule, good idea!

@JoshuaKGoldberg JoshuaKGoldberg removed this from the 6.0.0 milestone Feb 23, 2023
@bradzacher bradzacher modified the milestones: 6.0.0, 7.0.0 Mar 6, 2023
@bradzacher bradzacher added the enhancement New feature or request label Mar 15, 2023
@netlify
Copy link

netlify bot commented Apr 5, 2023

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 3a8b206
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/642db4d6f2fa4100085a20b0
😎 Deploy Preview https://deploy-preview-6426--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.

@nx-cloud
Copy link

nx-cloud bot commented Apr 5, 2023

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 3a8b206. 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 30 targets

Sent with 💌 from NxCloud.

@JoshuaKGoldberg JoshuaKGoldberg changed the title feat(typescript-estree): cache type checking APIs feat(typescript-estree): experimental option to cache type checking APIs Apr 5, 2023
@JoshuaKGoldberg
Copy link
Member Author

@bradzacher not-very-promising news on this:

  • Running time MEMOIZE_TYPE_CHECKING_APIS=true yarn lint --skip-nx-cache takes ~60 seconds for me - same as time yarn lint
  • Running time MEMOIZE_TYPE_CHECKING_APIS=true yarn lint-many runs out of memory (instead of taking ~110 seconds)

I think it'd make sense to ship this change, since it's small and additive and labeled as EXPERIMENTAL_. Thoughts?

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review April 5, 2023 17:49
@JoshuaKGoldberg JoshuaKGoldberg deleted the branch typescript-eslint:main July 10, 2023 17:52
@JoshuaKGoldberg
Copy link
Member Author

This was unintentionally auto-closed when we merged the v6 branch 🙃 it'll be recreated.

@JoshuaKGoldberg JoshuaKGoldberg changed the base branch from v6 to main July 10, 2023 21:11
@JoshuaKGoldberg
Copy link
Member Author

I'm more hopeful about the EXPERIMENTAL_useProjectService parser option (#6754). Closing this for now.

If someone does think this PR would benefit them, feel free to post an explanation why! We can always re-open - or even better, you the reader can open it and take ownership.

@JoshuaKGoldberg JoshuaKGoldberg deleted the cache-type-checking-apis branch July 17, 2023 19:29
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: Investigate caching type checking APIs
2 participants