-
Notifications
You must be signed in to change notification settings - Fork 12.8k
β‘ Performance: Project service spends excess time cleaning client files when called synchronously #59335
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
Comments
I will look into performance of cleanupProjectsAndScriptInfos but are you opening one file at a time. You batch open files using The cleanup is two folds:
This is already delayed portion where we dont do this immediately (like file delete or close) but on file open because in most cases projects and script infos in editor scenario can be reused by next file open. |
Unfortunately the access pattern of eslint itself is undefined; all it does is call the plugin to ask to parse a specific file. It doesn't provide the list up front or say when it's no longer using a file anymore... π |
Can you please try out #59689 (comment) to see if it helps |
I am also open to skipping this as an option but when do you suppose eslint will do "cleanup" to remove the files. We would need to expose that part as well. But I am trying to see if fast exits help or not before we do this. |
It does, fantastic! π Looks like most, but not all, of the performance discrepancy is gone:
I don't know. I've asked around internally. In the meantime, the best answer I can guess at is "eventually but not extremely soon". |
Till we have some idea on what to do here i dont think its advisable to let the collection not happen. In mean time we can get in that optimization PR |
Update: there's no plan to give this sort of information (whether ESLint is in single-run mode, when files are done being linted, etc.) to parsers. We should assume parsers in ESLint-land won't have access to that for a while. Anyway, thanks for working on this! Really encouraging to see so much of the performance discrepancy go away. β‘ |
Acknowledgement
Comment
π Search Terms
project service cleanupProjectsAndScriptInfos openClientFileWithNormalizedPath openClientFile
π Actual behavior
TypeScript project services open a file with
service.openClientFile(filePathAbsolute, ...)
. That internally calls to acleanupProjectsAndScriptInfos
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:
cleanupProjectsAndScriptInfos
.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
:The text was updated successfully, but these errors were encountered: