vscode-zig icon indicating copy to clipboard operation
vscode-zig copied to clipboard

Extremely Slow Formatting

Open sno2 opened this issue 3 years ago • 4 comments

Hello, I have files that are not even over 200 lines which format almost instantly when running zig fmt .. but with this extension VS Code hangs for at least 3 seconds every time. I'm not sure what is causing this but it is consistently slow on my machine despite the CLI having performant results. I am on Windows

sno2 avatar Jun 30 '22 04:06 sno2

Hmm, from looking at https://github.com/ziglang/vscode-zig/blob/master/src/zigFormat.ts it seems we don't use buffered IO and it is piped through stdin to JS and then written. Would it be possible to have Zig write to the files when it knows that the current open file is an actual file (not a scratch pad) and in the other cases use stdin?

sno2 avatar Jun 30 '22 04:06 sno2

I have never experienced any slowness on Linux even when formatting 26k+ line files. Are you sure you have the extension configured to use a release build of Zig? Have you tried using zls as the formatting provider?

Vexu avatar Jun 30 '22 07:06 Vexu

Hello, I have tried disabling all of the pertinent extensions all extensions except the Zig one and the problem still persists. I am not sure how to use zls as the formatting provider because when I do >Format Document With and then select the ZLS extension it does not do anything. Here's a video showcasing what happens every time for me:

https://user-images.githubusercontent.com/43641633/176674396-b60b56ac-4d44-4583-b36a-cf0466b714b9.mp4

.

sno2 avatar Jun 30 '22 12:06 sno2

@sno2 what is your CPU usage when formatting .zig file? If it's high, which process takes CPU time the most? Can it be somehow related to windows defender conflict? See #53

voltflake avatar Aug 24 '22 12:08 voltflake

This is no longer happening for me. Thanks

sno2 avatar Jul 13 '23 22:07 sno2