microsoft / microsoft/TypeScript
Use a data object instead of function closures for oldPrograms
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
Search Terms
structured clone algorithm, oldProgram, function closure
Suggestion
Create some transformer that transforms a Program to an OldProgram, which, instead of using function closures, would store the data, necessary for "rehydrating" a program, directly on the OldProgram object.
The createProgram function would then take a Program|OldProgram as the parameter for oldProgram.
The OldProgram object should be compatible with the structured clone algorithm, which would involve creating similar "serialized++" versions of all of the transitive objects contained in the data of OldProgram
Use Cases & Motivation
When caching a Program for use in a later compiler step, it contains many functions not consumed when taking in an oldProgram, these functions are needlessly holding variables in their closure/memory.
By trimming the methods down to only those used, the memory footprint is reduced, but they still have a memory cost of about 15MB for most of our projects (this number calcuated by observing ~2300MB freed after deleting 150 Programs from a cache). In our case this becomes ~22GB for all our projects. It would be nice to create a more lightweight version of these that can still be efficiently rehydrated for quick compiler actions.
This could also allow users in a specific use case to trim down the data more than is prudent to allow them to cache all of the Programs.
As an added bonus, if the OldProgram type could be made compatible with the structured clone algorithm, then it would be much easier to share a single, much larger, cache between a dozen-or-so compiler hosts.
As noted in #37701, compile times are slow when not able to reuse an oldProgram, this is aimed at helping users to be able to reuse an oldProgram more often.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
ファイルやテストは指定されていません。まず oldProgram と createProgram のエントリーポイントをたどり、次に issue #37701 と、ここで説明されている structured clone の要件を読んでください。クロージャベースのキャッシュデータを再ハイドレーション可能な OldProgram に置き換え、再利用を維持しながらメモリ使用量を削減できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers, performance
- issue の種類
- リファクタリング
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100