Skip to content

Conversation

sheetalkamat
Copy link
Member

@sheetalkamat sheetalkamat commented Aug 22, 2025

Parity with Strada:
Release program after emit - (this releases program all together and snapshot for now but it will be retained for --w like in strada)
Cache only source files for d.ts and json files as those are the ones that are exepected to be reused

Fixes #1622

@Copilot Copilot AI review requested due to automatic review settings August 22, 2025 04:13
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements parity with Strada by releasing programs after emit and optimizing source file caching. It focuses on memory management and performance improvements for the TypeScript compiler port.

Key changes:

  • Introduces program lifecycle management through MakeReadonly() to release programs after emit
  • Refactors program baselining to use a callback-based approach for better memory efficiency
  • Optimizes source file caching to only cache .d.ts and .json files that are expected to be reused

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/execute/watcher.go Adds program callback to testing interface during watch cycles
internal/execute/tsctests/sys.go Refactors program baselining from collection-based to callback-based approach
internal/execute/tsctests/runner.go Updates test runner to use new baselining interface
internal/execute/tsc/compile.go Removes IncrementalProgram array from command result, adds program callback interface
internal/execute/tsc.go Adds program callback invocation for non-watcher compilation
internal/execute/incremental/program.go Introduces MakeReadonly() method and refactors testing data structure
internal/execute/incremental/emitfileshandler.go Updates to use new testing data structure
internal/execute/incremental/affectedfileshandler.go Updates to use new testing data structure
internal/execute/build/host.go Optimizes source file caching to only cache .d.ts and .json files
internal/execute/build/buildtask.go Implements program release after emit using MakeReadonly()
Comments suppressed due to low confidence (1)

internal/execute/incremental/program.go:312

  • This function is now empty and appears to be unused. Consider removing it if it's no longer needed, or add a comment explaining why it's kept as a stub.
		return

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@jakebailey
Copy link
Member

Cache only source files for d.ts and json files as those are the ones that are exepected to be reused

I'll be curious if in the future we can still cache input ts files, given people can use build mode to parse out the same set of files multiple times, e.g. for tests or for multi-emit-formats. But, from your wording, it sounds like you're saying that Strada did not do this?

@sheetalkamat
Copy link
Member Author

sheetalkamat commented Aug 22, 2025

Cache only source files for d.ts and json files as those are the ones that are exepected to be reused

I'll be curious if in the future we can still cache input ts files, given people can use build mode to parse out the same set of files multiple times, e.g. for tests or for multi-emit-formats. But, from your wording, it sounds like you're saying that Strada did not do this?

yeah - with project references - we will reference output file - which is d.ts file for the common projects so its very rare to have .ts files hence we didnt cache them - also that increases foot print in memory which bigger problem in Strada so we have has some optimizations there.

Esp imaging programs with 60k+ files, it quickly adds up

@sheetalkamat sheetalkamat enabled auto-merge August 22, 2025 04:19
@sheetalkamat sheetalkamat added this pull request to the merge queue Aug 22, 2025
Merged via the queue into main with commit 15ae26c Aug 22, 2025
22 checks passed
@sheetalkamat sheetalkamat deleted the releaseProgram branch August 22, 2025 04:36
zshannon pushed a commit to zshannon/typescript-go that referenced this pull request Oct 6, 2025
… source files (microsoft#1623)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
zshannon pushed a commit to zshannon/typescript-go that referenced this pull request Oct 6, 2025
… source files (microsoft#1623)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug] tsgo --build uses extreme amounts of memory
2 participants