Description
Acknowledgement
- I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion.
Comment
🔎 Search Terms
project service cleanupProjectsAndScriptInfos openClientFileWithNormalizedPath openClientFile
🙁 Actual behavior
TypeScript project services open a file with service.openClientFile(filePathAbsolute, ...)
. That internally calls to a cleanupProjectsAndScriptInfos
to clean up projects, such as removing orphans. There's no way to skip that cleanup.
When using typescript-eslint's parserOptions.projectService
, that cleanup adds (seemingly?) unnecessary overhead per file being linted.
🙂 Expected behavior
When I tried commenting out its contents of cleanupProjectsAndScriptInfos
locally, the time for a lint run of ~1024 files with the project service speed up by ~15-20%, from ~3.2 seconds to ~2.5 seconds. ⚡
Request: could we add an option to the ProjectService
class to skip cleanups, please?
Alternate request: failing that, maybe the cleanups can be debounced and/or delayed in some way? E.g. added to a queue that only executes if the project service is still active?
Additional information about the issue
On the TypeScript side:
- Point of comparison: JoshuaKGoldberg@2ae3568 would be one way of doing this.
- Handle config file change and default project management #58486 is the PR that introduced
cleanupProjectsAndScriptInfos
.
On the typescript-eslint side:
- https://github.com/typescript-eslint/performance is the performance repository showing how to create these profiles.
- https://github.com/typescript-eslint/performance/blob/main/README.md#comparison-project-service-client-file-cleanups has the measurements for this specific investigation.
- feat(typescript-estree): add EXPERIMENTAL_useProjectService option to use TypeScript project service typescript-eslint/typescript-eslint#6754 is the PR that first added usage of the project service in typescript-eslint.
- We in ESLint-land can't explicitly tell TypeScript when files are opened or closed: feat: parsing session objects eslint/rfcs#102. But in typescript-eslint specifically we have an inference of when we're in "single-run" mode: https://v8--typescript-eslint.netlify.app/packages/parser#disallowautomaticsingleruninference.
cc @sheetalkamat as FYI, after a pairing with @jakebailey.
@jakebailey suggested I also include a screenshot like this speedscope.app view of an ESLint CLI run with parserOptions.projectService
: