Skip to content

⚡ Performance: Project service spends excess time cleaning client files when called synchronously #59335

Closed
@JoshuaKGoldberg

Description

@JoshuaKGoldberg

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:

On the typescript-eslint side:

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:

speedscope.app time order view of an ESLint CLI run, find-highlighting multiple wide instances of 'cleanupProjectsAndScriptInfos'

Metadata

Metadata

Assignees

Labels

APIRelates to the public API for TypeScriptDomain: PerformanceReports of unusually slow behaviorFix AvailableA PR has been opened for this issueInfrastructureIssue relates to TypeScript team infrastructure

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions