microsoft / typescript-analyze-trace

A tool for analyzing the output of `tsc --generateTrace`
MIT License
334 stars 19 forks source link

Feature: Program Construction #2

Open amcasey opened 2 years ago

amcasey commented 2 years ago

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.

amcasey commented 2 years ago

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.

amcasey commented 2 years ago

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".

amcasey commented 2 years ago

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.