GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fixes the issue with emit where in same file is emitted multiple times by sheetalkamat · Pull Request #19306 · microsoft/TypeScript

Conversation

@sheetalkamat

@sheetalkamat Sheetal Nandi (sheetalkamat) commented Oct 18, 2017

Copy link
Copy Markdown
Member

Before this change, all the affected files list was emitted and the file write callback was used to ensure we mark duplicate source files that would result in computing same output file (eg with --out) The issue with this was that writeFileCallback doesn't list .d.ts files as computing to same output files, yet emit with that file as sourceFile emits the same --out file. This means whenever there are multiple d.ts files are present in affected file list, it would result in same file being emitted multiple times.
The problem got worse since builder always created emit output in memory, which means till all the changed files are written to disk those huge strings and other data exists in memory. That means you can run out of memory pretty soon. (Resulting in #19253)

This fix deals with this by:

  • emitChangedFiles in the builder doesn't generate output in memory, instead it takes the writeFileCallback (just like program::emit method)
  • Do not record deleted files in changedFileSet since they are anyways not going to result in any kind of emit
  • With this, now if there there is even a single file in changedFilesSet, and emit is going to use single file to output, just emit it. since with any change in program file (whether it changes shape or not) same file is going to be emitted
  • Do not cache semantic diagnostics when --out or --outFile is specified since we would anyways need to remove the diagnostics for the files that result in this emit
  • Also now store the files that have already computed if the shape was changed. This helps in not returning the file as updated shape multiple times. This is needed to ensure we don't compute same d.ts files again and again to see if signature is updated.
  • For declaration file, use its version as the signature instead of text so that we don't need to compute hash for them.

Apart from this another TODO and to think in future to see if we can ensure that emitter always emits just declaration file without doing any additional diagnostics/no emit checks. This would help in figuring out dependencies correctly. Right now in all these cases (for some reason emit is skipped) shape is assumed to be Skipped.

Fixes #19253

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Sheetal Nandi (sheetalkamat) added 5 commits October 18, 2017 13:34
@sheetalkamat
Add failing testcase where when d.ts file is in program, the files ge…
d3f954e
…t emitted multiple times with --out setting
@sheetalkamat
Use get files affected by internally and hence use file paths as input
f9c901a
@sheetalkamat
Modify api to emit affected files using callback instead of generatin…
8fbfb5f
…g in memory output

Also marking few apis introduced during watch improvements changes that are suppose to be internal for now
@sheetalkamat
Simplify emit changed files further
835d7cb
Also use source file version as the signature of declaration file instead of computing it from text
@sheetalkamat
Do not cache the semantic diagnostics when compiler options has --out…
7e780c0
… since we would anyways get all fresh diagnostics
mhegazy
Mohamed Hegazy (mhegazy) reviewed Oct 18, 2017
View reviewed changes
Comment thread src/compiler/builder.ts Outdated
const cachedDiagnostics = semanticDiagnosticsPerFile.get(path);
// Report the semantic diagnostics from the cache if we already have those diagnostics present
if (cachedDiagnostics) {
cachedDiagnostics;

@mhegazy Mohamed Hegazy (mhegazy) Oct 18, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

did you mean return cachedDiagnostics ?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sheetalkamat
Actually use cached semantic diagnostics
9bea0db
mhegazy
Mohamed Hegazy (mhegazy) approved these changes Oct 18, 2017
View reviewed changes

@mhegazy Mohamed Hegazy (mhegazy) left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

One comment about the missing return for diagnostics

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sheetalkamat
Sheetal Nandi (sheetalkamat) merged commit 8fc6518 into master Oct 18, 2017
@sheetalkamat
Sheetal Nandi (sheetalkamat) deleted the doNoWriteFilesMultipleTimes branch October 18, 2017 23:12
@microsoft Microsoft (microsoft) locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

1 more reviewer
@mhegazy Mohamed Hegazy (mhegazy) mhegazy approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2.6 takes a very long time to --watch on large projects

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@sheetalkamat @mhegazy
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.