Skip to content
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

Do not calculate signatures if old state is not used #43314

Merged
merged 5 commits into from
Mar 23, 2021

Conversation

sheetalkamat
Copy link
Member

@sheetalkamat sheetalkamat commented Mar 19, 2021

Changes in this:

  1. If the old state was not present or not used, we set flag that says instead of calculating signature for a file (which is dts emit hash) use the version of file as the signature.
  2. This makes it so that initial compilation will not calculate the d.ts emit and next file change to the file will be treated as non local change and thats when the signatures for file reference dependency are calculated and it would probably result in emitting more files than necessary but thats the compromise for not having to spend cost for d.ts emit in the initial round. The next change to that file should be able to correctly detect local/non local change as before.

925e70e Just updates tests to ensure we are testing the scenarios we intended.
dd1cef2 is actual change and may be ideal to look at the changes as part of that commit.
69ebfe3 Checks updates to the incremental correctness of the program, essentially signature is same as d.ts emit signature or version of the file. Also exported modules map is checked in similar way.
44ba0ec Reverts the compileOnSave to old behavior of always computing signature

This is simplified implementation of work in #42960 by @sokra
There are more todos that we can improve on, eg if global file is changed, mark it for lazy signatures etc but i think that each change should be separate change to be able to evaluate the perf impact and if needed revert it.
Potential improvements:

  1. Global file change => resulting in emitting all files so could benefit from using signature as version
  2. Certain number of new files percentage
  3. Certain number of changed file percentage

@@ -951,7 +951,7 @@ function bar() {
}

// Change file1 get affected file list
verifyLocalEdit(file1, "hello", "world");
verifyLocalEdit(file1, "hello", "world", /*returnsAllFilesAsAffected*/ !declaration); // Signatures are not initialized before this request
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if compileOnSave should disable this behavior given it doesnt save all files so will be anyways calculating signatures for affected set and not going to change from one edit to next ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sheetalkamat Can you please elaborate? I think you're saying

  1. Old behavior: compute (emit?) .d.ts on compile-on-save
  2. New behavior: don't compute (emit?) .d.ts on (first?) compile-on-save
  3. Proposed behavior: restore old behavior

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If @amcasey's explanation is correct, then yes - my instinct says that compile-on-save should compute+emit .d.ts.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes thats what i meant.. i will revert to old behavior for compile on save

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated and ready for review

@amcasey
Copy link
Member

amcasey commented Mar 19, 2021

Does this make the first watch build as fast as a non-watch build or is there still some overhead?

@sokra
Copy link
Contributor

sokra commented Mar 22, 2021

Does this make the first watch build as fast as a non-watch build or is there still some overhead?

yes, it should be about as fast. There is probably still an overhead, but it's unnoticeable.

Copy link
Contributor

@sokra sokra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some basic benchmarking and it works as expected for the usual cases.

@sokra
Copy link
Contributor

sokra commented Mar 22, 2021

The following unusual case is still slow: Broken config file, compile, fix config file, compile.
It's like adding a lot of files and causes a lot of signatures to be computed. But this can be solved in a follow-up PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants