Skip to content

⚡ Performance: parserOptions.projectService sometimes no longer outperforms parserOptions.project #9571

Open
@JoshuaKGoldberg

Description

Overview

When we first started working with the new parserOptions.projectService (formerly parserOptions.EXPERIMENTAL_useProjectService), it outperformed equivalent parserOptions.project setups by ~10-15%. We still sometimes have users report to us that it improved their linting speed. trpc/trpc#5868 is an example of one observation I've made.

However, at some point since then, we've started to notice worse performance of parserOptions.projectService in our own measurements. https://github.com/typescript-eslint/performance contains tooling to test this. From https://github.com/typescript-eslint/performance/blob/45f77c00c6d4384d466c39e8eb633a76f33dd019/README.md#results:

┌───────┬──────────────────────┬──────────────────────┬──────────────────────┬──────────────────────┐
│ files │ project (even)       │ project (references) │ service (even)       │ service (references) │
┼───────┼──────────────────────┼──────────────────────┼──────────────────────┼──────────────────────┤
│ 128   │ '1.149 s ±  0.030 s' │ '1.135 s ±  0.008 s' │ '1.178 s ±  0.010 s' │ '1.736 s ±  0.012 s' │
│ 512   │ '1.636 s ±  0.009 s' │ '1.656 s ±  0.004 s' │ '1.895 s ±  0.007 s' │ '2.613 s ±  0.020 s' │
│ 1024  │ '2.353 s ±  0.013 s' │ '2.399 s ±  0.016 s' │ '3.130 s ±  0.017 s' │ '4.034 s ±  0.061 s' │
┴───────┴──────────────────────┴──────────────────────┴──────────────────────┴──────────────────────┘

Summarizing those results, there seem to be two areas of slowness. Comparing project to projectService at ~1024 files:

  • Overhead per-file ((even)), jumping from ~2.35s to ~3.13s
  • Overhead switching to project references ((references)): jumping from ~2.4s to ~4.0s`

⚠️ These measurements might be flawed. We are not sure there's not some external data polluting the results. This issue might just be tracking that we're measuring them incorrectly.


Also note that parserOptions.project has been in production for years, with many performance optimizations around it. parserOptions.projectService is very new and not yet stable. There is likely much more "low-hanging fruit" to optimize around parserOptions.projectService.

We don't yet know whether this is an issue in TypeScript or typescript-eslint. It's probably typescript-eslint.

Relevant past issues:

Metadata

Labels

accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workingperformanceIssues regarding performanceteam assignedA member of the typescript-eslint team should work on this.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions