microsoft/typescript-analyze-trace

Feature: Program Construction

amcasey opened this issue · 3 comments

We can already detect and report program building hot-paths (chiefly in findSourceFile), but the output is confusing. We would need to identify imports with high self time and then report causal chains for those.

The concept of causal chains is less straightforward than it seems because the trace really indicates the first reason that a file was included - eliminating that reason may not prevent the file from being loaded for some other reason.

Another possibly interesting heuristic would be to look for events with high fanout (e.g. barrel module), but this goes against the grain of the tool, which tries to drop the many inexpensive children. It seems like it would need to happen before that pruning, perhaps by persisting an "original child count".

Another thing to look for is npm_modules that are included from more than one path - having two versions of the same package tends to slow down checking a lot because so many structural comparisons of similar types are required.