-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Build mode explicitly checks file stamps in watch mode rather than using file watcher events #45082
Comments
Thanks for reporting this - would you be able to profile the compiler on both builds? Minimally just with |
The same for me. It happens on every project which I tried. |
@DanielRosenwasser You can try it here: https://github.com/deftomat/typescript-build-watch-perf On my PC, recompilation took 2.5s with Our goal is to be able to run However, it is just too slow right now. Larger packages easily took 15s even on small changes. |
@DanielRosenwasser is the repro created by @deftomat helpful here, or you would prefer us to generate some more input? This particular GitHub issue is kinda deal breaker for us... we would love to switch to single-tsc build-watch process for the entire monorepo, but we can't due to this perf aspect, so we have to run one tsc instance for each of inter-dependent projects in the monorepo (more than 5 so far) and suffer from them being watch-rebuilt with errors multiple times (until it finally settles) after pulling from Git, when multiple monorepo projects change at the same time. With -w -b being as fast as -w, this problem would go away and significantly simplify the dev experience. |
Sorry for the delay. I (unnecessarily?) spent a bit of time in pprof and basically saw that I tossed a |
@dko-slapdash Have you tried with 4.4 RC? It includes a bunch of fixes specifically for closing the gap between project-mode and build-mode perf. |
I'd be pretty surprised if #43995 wasn't a factor. Edit: it's not. |
@deftomat Can you tell me more about your repro steps? Which project are you building when you don't pass Ignoring watch mode for a second, here's what I'm seeing:
i.e. Build mode is ~10% slower, rather than the 8X you're seeing. This is with 4.5.0-dev.20210813. Also, you mention "recompilation" - what edit should I be making to see those incremental build times? Thanks! Edit: I believe I have a repro, building packages/api with both |
@amcasey Just tried 4.4.0-beta. Still the similar effect. Below is a screencast which illustrates that sitting in a leaf monorepo package, Code.-.__git_slapdash_packages_worker_src_lib_worker_indexAppFullJob.ts.mp4// packages/worker/tsconfig.json
{
"extends": "../../tsconfig.base.json",
"include": [
"src/**/*"
],
"compilerOptions": {
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo",
"rootDir": "src",
"outDir": "dist",
"paths": {
"slapdash-shared/dist/*": [
"../shared/src/*"
],
"slapdash-server/dist/*": [
"../server/src/*"
],
},
"lib": [
"es2019",
"esnext.asynciterable",
"DOM"
],
"module": "commonjs",
},
"references": [
{
"path": "../shared"
},
{
"path": "../server"
},
]
}
// tsconfig.base.json is the same as mentioned in the initial post |
@dko-slapdash Thanks for the update! I believe I have a reliable repro, so I've already started profiling. Unfortunately, this looks separate from \the issues we fixed in the RC. |
My first impression is that all the extra time is spent on file existence checks. 😢 |
Seeing the same behavior. While this is being investigated, is there a version that does not have this problem? |
@xasopheno I tried a few and they all behave like the latest one. |
I'm pretty sure this isn't new. It looks like regular watch mode is depending on file watchers to catch file changes and build-mode watch is redoing the mtime checks every iteration. An issue like that is generally baked in from the beginning. |
@amcasey You think that the extra time is all explained by file mtime checks? On our end, the difference in |
@dko-slapdash It's not just the Out of curiosity, how did you could your mtime checks? |
@amcasey Thanks! How did I what, sorry? |
@dko-slapdash How did you count your mtime checks? 🤦 |
Seeing the same performance difference. |
@amcasey do you think it would be possible, design wise, to get the same speed than watch mode? |
@sledorze My intuition is yes, but it's a pretty complex area and it might be an expensive change. |
@amcasey thanks for the reply from your answer, do you think it may be scheduled in the mid (if not short) term, knowing the possible impact ? |
@sledorze Sorry for the frustrating experience. I can't make any promises but of course this will be considered as we draw up the iteration plan for the next release. |
So when it came to checking file stamps, it was about checking the output file stamps, right? I've opened #46677 as a possible strategy to circumvent this. |
I believe this is the same issue as #31932 |
If people here would be willing to try out tomorrow's nightly build, we'd appreciate the feedback! |
Bug Report
In a monorepo with composite projects, adding
-b
slows down the--watch
mode reaction time, even whentsc -b --watch
is run inside somepackages/shared/
project which has 0 references in its tsconfig.json. The compilation time is like 3.4s vs. 0.3s when used without -b on a small sub-project, and is way higher for large projects (or even whentsc -b --watch
is executed in the root).In both of these cases, tsBuildInfoFile is utilized (and successfully updated).
🔎 Search Terms
tsc watch build slow
I found #42960, but not sure it's about the same topic: it says nothing about --build and non-build modes.
🕗 Version & Regression Information
@next 4.4.0-dev.20210716
💻 Code
🙁 Actual behavior
tsc -b --watch
compiles a single changed file way slower thantsc --watch
.🙂 Expected behavior
They work at comparable speeds.
The text was updated successfully, but these errors were encountered: