microsoft / typescript-analyze-trace

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

Consider using another metric than time to check for hot spots #28

Closed julienfouilhe closed 2 years ago

julienfouilhe commented 2 years ago

This tool is great, I solved a few problems thanks to it.

So I thought that I would add it as a step of our CI to prevent regressions or adding new performance issues. But our CI runs on much slower machines than mine so it catches a lot more things.

Isn't there a metric more constant that this tool could be based on to figure out how much typescript has to work and where things could be improved?

amcasey commented 2 years ago

@julienfouilhe Thanks for the feedback! I'm not sure I understand your question though. It sounds like you're asking whether the tool could highlight the parts of compilation that are relatively slow, so that it would be independent of the speed of a particular machine (though probably not independent of machine architecture or node version) but, if so, I'm not sure how you could integrate such a check into your CI. Can you please elaborate?

In the meantime, some thoughts on perf testing in CI:

My two cents. :)

julienfouilhe commented 2 years ago

@amcasey Thank you for your answer!

Our main problem currently is not the global time of compilation, but in parts of our app working with typescript in vscode is extremely slow and I was hoping removing hot spots would solve those devX problems. The thing is I expect other developers to find some of the changes made to remove those hot spots strange and to revert them, hence why I wanted to include this tool in our CI.

What I would do before I used this tool was analyze the trace and investigate chunks that were "bigger" than the others. When I created this issue I was thinking that maybe another metric could be made available in traces to know how much work Typescript has to do to resolve something. In my mind a metric like that would make this tool much more reliable and useful. I understand that maybe this metric doesn't exist and would be impossible to maintain in the typescript codebase.

But thanks anyway, you're right I'll play with the threshold options to find something that works with our CI!

amcasey commented 2 years ago

Oh, I see now. Yeah, I did actually think about that when I was prototyping this work. I experimented with using the number of types allocated as a proxy for time to make traces reproducible. I ended up abandoning the approach for reasons I don't fully recall (I assume they must have been quite good since, as you point out, the advantages are substantial). Off the top of my head, I would guess that there were too many false positives - sometimes a lot of types are generated very cheaply and investigating those areas doesn't make sense. It also doesn't generalize well to other phases, especially module resolution.

Unfortunately, I think the threshold options are your best option for now. Thanks again for reaching out!