Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extremely Slow Formatting #63

Closed
sno2 opened this issue Jun 30, 2022 · 6 comments
Closed

Extremely Slow Formatting #63

sno2 opened this issue Jun 30, 2022 · 6 comments

Comments

@sno2
Copy link

sno2 commented Jun 30, 2022

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
Copy link
Author

sno2 commented Jun 30, 2022

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?

@Vexu
Copy link
Member

Vexu commented Jun 30, 2022

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?

@sno2
Copy link
Author

sno2 commented Jun 30, 2022

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:

2022-06-30_07-09-24.mp4

.

@voltflake
Copy link

voltflake commented Aug 24, 2022

@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

@sno2
Copy link
Author

sno2 commented Jul 13, 2023

This is no longer happening for me. Thanks

@sno2 sno2 closed this as completed Jul 13, 2023
@Pyrolistical
Copy link

still very slow on windows.

zig version
0.12.0-dev.2063+804cee3b9

ziglang.vscode-zig v0.5.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants