-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Perf Regression - Excessive time spent in realpath in build mode #46204
Comments
FYI @weswigham |
Without having looked into it, my intuition is that the paths in the cache should already be in the desired form so that this realpath call should be unnecessary. Failing that, it might be appropriate to do an existence check before calling realpath. |
Is realpath expensive when performed on non-existent paths? (Moreso than existence checks?) We definitely look up more paths now, since previously we weren't looking up these files during incremental mode at all (and so would never pick up changes to them) - and technically, there are a lot of possible locations for these files (all of which should be injected into our caches), since a package file could appear at any of the parent directories above a given file. |
@weswigham I seem to recall that it will throw if the path doesn't exist, but I may be thinking of a different IO call. |
JFYI - one way to speed up the failure case is to freeze Error.stackTraceLimit to 0 for the duration of the fs call. Freezing this value is only supported in more recent versions of node, though - so may need some capabilities check if you want to use that |
@weswigham @amcasey initially it was intentional that we never watched package json files because build mode is suppose to only watch input files and use those time stamps for up to date ness ( we do not watch any module resolution stuff , if you want to do that , it’s watch mode on individual project as it’s too costly to do that when building solutions - list of projects ). Just fyi .. |
It does, yes - it throws an
We actually do this for |
|
Assume you are referring to here: TypeScript/src/compiler/sys.ts Line 1814 in 7fc1cb4
But this doesnt totally work as expected, as node will just set it back to Infinity (so long as stackTraceLimit isnt frozen) To actually not capture the big trace, you need to set the value as non-writeable
|
👀 That's.... eck. Maybe we can just make more PRs for |
Profiling an internal codebase yielded the following
The first line is self explanatory and the second suggests that a lot of those realpath calls are for non-existent paths.
The calls are coming from https://github.com/microsoft/TypeScript/pull/44935/files#diff-0558af289c76f66611354da63a14152fe5cd3a72b3c3e59eb880808efc2df442R876.
Local testing confirms that the build is much slower after this commit than before.
The text was updated successfully, but these errors were encountered: