perf: remove ts resolved module cache file #4293
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
I noticed that running ts-jest was very slow in one of my projects so I dig a little into why and noticed the performance bottleneck comes from the
getCacheKey
function and in particular thewriteFileSync
that is being called to store the dependency graph.Writing this file is what's taking most of the time in this process as the content we write is very heavy : the whole file content and its resolved module names.
I ran a few tests on a project with different configurations and here are the result:
--no-cache
)As we can see from the results, the fastest way to run ts-jest is by disabling jest cache (
--no-cache
) but we can get pretty close to that timing when we skip writing the dep graph file.What's even more interesting is that on subsequent runs, even reading the dep graph file is less performant than recomputing the graph (2s less in this case)
So I'm opening this PR to completely remove the dependency graph file as it seems to only slow down the process without any gain. It should largely improve ts-jest performance when not using isolated modules.
Fixes #2696
Test plan
Does this PR introduce a breaking change?
Other information