really write output file only if needed#13776
really write output file only if needed#13776gdh1995 wants to merge 2 commits intomicrosoft:masterfrom gdh1995:write-file-only-if-diff
Conversation
|
Hi @gdh1995, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! The agreement was validated by Microsoft and real humans are currently evaluating your PR. TTYL, MSBOT; |
|
Has #6937 already implemented incremental building? If I have read the comment and code in #6937 correct, output will be skipped iff 1. the complied result changed and 2. someone other than compiler touched the file, regardless of modification. Indeed reading file again and computing hash will skip some emission in certain case of 2. But I'm not sure whether it will outweigh the cost of reading/hashing relative to a |
|
Updated secondly: My second commit makes watcher re-skip iff two fingerprints match, and the watcher will check content on the first time (on initing the fingerprint map). Old content@HerringtonDarkholme No, because #6937 only takes effects when However, this PR makes Updated: I made a mistake that Currently this PR has enabled all |
1. reset fingerprint.updated to false if no more changes found 2. write directly without pre-reading if fingerprint is not matched 3. still check file content during the first time of compiling process
|
What issue tracks this change? In general the updating of an output file's timestamp is a good thing because it allows incremental build tools (e.g. |
|
@gdh1995, thanks for the contribution. as a general policy, please file an issue first before submitting a change. I do not think we would want to take this change. Most build systems do check time stamps before calling the compiler, e.g. gulp, MSBuild, etc.. so this is redundant, and all users have to pay this price regardless if they care about this feature or not. |
This PR makes
tsconly does really writing if an output file's content / BOM has been changed.If one file is not updated, the log message will be:
TSFILE (no changes): R:/Google/a.jsIntention
Although this slows down the compiler a little, I thinks it's a bad design to always write disk a lot everytime I change a single little file in my project.
For example, I'm migrating a JavaScript project to TypeScript, and I want to keep most of the built code same as the old, so I need to call
tscoften. Heretsc --watchis useful, but it changes files' mtime frequently and makedifftools andzipdo some unnecessary works.