typespec icon indicating copy to clipboard operation
typespec copied to clipboard

Bad compiler performance

Open VictorVermeulen opened this issue 1 year ago • 4 comments

Describe the bug

  • typespec server slow and keeps crashing in vscode
  • duplicate model error when running tsp compile main.tsp (see readme of reproduction)

I think they are not related but figured it could be because of something that is infinite looping causing the server crash, that is why I left it in here.

When starting the typespec server, going to definitions is slow/does not work (when ctrl + hovering you see loading...). If you restart the typespec server then and see the output, you see that the server crashed.

When running the compiler you also see a duplicate model error, commenting out that does fix it, but I figured to leave it in here in case it is related.

When there is an error somewhere in the code, the typespec error does not crash. This leads me to believe that maybe there is a bug with importing files (or obviously I am doing something wrong)

Reproduction

https://github.com/VictorVermeulen/typespecdebug/tree/master

Image

Checklist

VictorVermeulen avatar May 08 '25 17:05 VictorVermeulen

Split the error part into this issue #7294

timotheeguerin avatar May 08 '25 19:05 timotheeguerin

Thank you for reporting this issue!

The performance issue was related to an unoptimized function used by a dependency of the openapi3 emitter (asset-emitter). https://github.com/microsoft/typespec/pull/7306 optimizes that function to improve its performance ~100x. When I tested against your repo locally, this function (called over 100,000 times for your repo) was taking ~6-7 seconds of the emit time, now down to ~60-70 ms.

chrisradek avatar May 09 '25 17:05 chrisradek

The performance issue should be resolved now with the just released @typespec/asset-emitter version 0.70.1. Do you mind installing that version and let us know if that solves the performance side of things for your project?

chrisradek avatar May 09 '25 22:05 chrisradek

Hi @chrisradek It looks to be working indeed! Thanks for taking care of this in just a few days, much appreciated.

VictorVermeulen avatar May 12 '25 07:05 VictorVermeulen