Added caches to tsc's CompilerHost#27068
Added caches to tsc's CompilerHost#27068timocov wants to merge 2 commits intomicrosoft:masterfrom timocov:addCachesToTscHost
Conversation
sheetalkamat
left a comment
There was a problem hiding this comment.
I don't think we want this in compiler host. Just like #26259 the user of createProgram can always cache the results it wants. Eg. You can move this to tsLoader to cache this instead of of affecting usage of tsc
Now it is in tsc (not in the compiler host), is it ok?
I totally agree with it. I guess that
But what if we want to compile via cli |
|
@sheetalkamat you marked this PR as "requested changes", but can you please say what kind of changed I need to do? Or it means that this PR never will be merged? |
|
@RyanCavanaugh @DanielRosenwasser anybody? 🙁 |
|
@RyanCavanaugh Any updates? |
Related issues: #26871, TypeStrong/ts-loader#825.
After debugging the compiler I have been noticed that some functions are called multiple times with the same arguments (for example, in our project
tsctried to check thattslibfile exists almost 3k times).Quite possibly that such behavior is related to set
baseUrlcompiler option.For example, I have observe the following situation in our project (I don't understand what exactly affects on this):
Let's say that some file is placed
/project/src/sub-folderfolder,baseUrloption is set to./src,importHelpersoption is enabled, and the file needs to import helpers fromtslib.In our case we get the next requests in
tryFilefunction:This requests are made before
tslibis resolved from/project/node_modulesfolder.tscmakes at least 14 extra syscalls. But yeah, we can have localtsliband then resolving will stop.The same resolving will be performed for all other files from
/project/src/sub-folderfolder.Perhaps this example is related to
tslibonly, and for other imported modules the compiler makes less requests.This PR adds caches for some CompilerHost's functions while compiling via
tsc.Below are some diagnostics for our project (average of 3 runs).
(our project is not compiled with
masterbranch yet due #26978, but I believe the differences will be very similar)typescript@3.0.1 (from npm):
release-3.0 branch with applied fixes:
Difference:
I believe that here only
Program timeandTotal timeare valuable.I hope this fix can help someone improve its build speed.
Open questions:
createCompilerHostfunction instead? If so, what aboutcreateSolutionBuilderHostintsbuild.ts- it seems that it usescreateCompilerHostas host for watch mode?createWatchCompilerHost? It is possible that we can use caches while compilation and clear it right before compilation start.