microsoft / microsoft/TypeScript

Rewrite `getAccessibleSymbolChain` for performance

オープン
#33,624 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Domain: Declaration Emit Domain: Performance Experience Enhancement
主要言語
Go
スター
111k
フォーク
14.4k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

getAccessibleSymbolChain is one of the oldest parts of the compiler - remaining today mostly unchanged (barring support for new features) from when it was used in the old text-based declaration emitter. getAccessibleSymbolChain is used to, given a [symbol, scope] pair, find a series of symbols whose exports can be accessed to lookup the symbol. Today, this is by and large uncached, so the fail case, when a symbol is not accessible, causes a traversal of every publicly reachable symbol in a program - this process is then repeated for every symbol that needs to be named, which means you end up spending a very long time traversing symbol structures. On normal typescript code, the inefficiency is less outsized, as we only need to invoke this code when we generate inferred types in declaration emit, which is more rare in TS output than in JS output, however you can still find projects where its' influence is large (some of @AnyhowStep 's samples bad performance in declaration emit trace back to this).

As far as the direction of the fix goes - I have some ideas. Today, we enumerate all possibilities and just backtrack to see what works - instead, I imagine using a (cacheable) set-like structure to check if the symbol is even accessible from a given symbol, and then use a hierarchy of these sets to guide chain creation.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、コンパイラー内で getAccessibleSymbolChain を見つけ、declaration emit 中の呼び出し元を追跡します。既存のシンボル走査と issue で言及されているパフォーマンストレースを確認し、そのうえで、accessible symbol chain の結果を変更せずに、繰り返しの走査が削減されたことを検証する方法を決定します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
compilers, performance
issue の種類
リファクタリング
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
30/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。