Skip to content

Stop using expensive directoryExists in unit/rwc tests where it does not matter #19486

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

Merged
merged 1 commit into from
Oct 26, 2017

Conversation

weswigham
Copy link
Member

The harness directoryExists implementation iterated over every file in the compilation to see if any started with the given path in order to return true. directoryExists is only used as a "shortcut" in module resolution to avoid doing exists calls on a bunch of files within a directory. In the test harness, unlike on disk, the directory exists check is crazy expensive for large tests (like RWC tests - this was ~20s of time on our largest test!), while the file stat is almost free.

With this change, the harness directoryExists implementation becomes () => true for all tests where the difference is not observable - the old implementation is now only used by tests which baseline module resolution traces.

@weswigham weswigham requested review from sandersn and mhegazy October 25, 2017 23:19
@weswigham weswigham merged commit 1a6022d into microsoft:master Oct 26, 2017
@weswigham weswigham deleted the simple-directory-exists branch October 26, 2017 00:04
@mihailik
Copy link
Contributor

Note that directoryExists is declared as optional in types.ts ModuleResoultionHost (which CompilerHost extends):

https://github.com/Microsoft/TypeScript/blob/a6555921f4b1d51281b1241c69e91e5b82d2f07e/src/compiler/types.ts#L4012

I would have thought cases like that is exactly where null would make sense?

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants