zls icon indicating copy to clipboard operation
zls copied to clipboard

Massive ZLS textDocument/codeAction delay

Open xydone opened this issue 1 year ago • 2 comments

Zig Version

0.13.0

ZLS Version

0.13.0

Client / Code Editor / Extensions

VSCode with Zig Language extension

Steps to Reproduce and Observed Behavior

Writing code leads to a big slow-down in intellisense, which in itself leads to me being unable to save the file for a long period of time as formatOnSave is trying to run, but is unable to. When I check ZLS' output in VSCode, I see a massive spike in ms for textDocument/codeAction whenever the issue occurs. However, I do not have clear steps of reproduction as it happens randomly, yet often.

Things I have tried:

  1. Running latest Zig and latest ZLS
  2. Reinstalling VSCode Zig Language extension
  3. Reinstalling VSCode
  4. Testing with a different lightweight codebase (~50 lines) to see if it still occurs and it does.
  5. Checking if my PC resource utilization is not normal and it is indeed normal. I have also tried restarting my PC multiple times, to no avail.
  6. Checking if my VSCode Zig extension settings are correct and they seem to be. I have attached them below:
  "zig.initialSetupDone": true,
  "editor.multiCursorLimit": 20000,
  "zig.path": "zig",
  "zig.zls.path": "zls",
  "git.ignoreRebaseWarning": true,
  "workbench.statusBar.visible": false,
  "zig.zls.debugLog": true,
  "zig.checkForUpdate": false,
  "zig.zls.warnStyle": true

Expected Behavior

Normal ZLS usage with low latency

Relevant log output

(... normal logs ...)
debug: (server): Took 0ms to process notification-textDocument/didChange on Thread 14792
debug: (server): Took 0ms to process notification-$/cancelRequest on Thread 16892
debug: (server): Took 0ms to process notification-$/cancelRequest on Thread 23452
debug: (server): Took 0ms to process request-12810-textDocument/inlayHint on Thread 23236
debug: (server): Took 0ms to process request-12817-textDocument/semanticTokens/full on Thread 23236
debug: (server): Took 0ms to process notification-$/cancelRequest on Thread 23236
debug: (server): Took 0ms to process request-12815-textDocument/inlayHint on Thread 14792
debug: (server): Took 0ms to process notification-$/cancelRequest on Thread 14792
debug: (server): Took 0ms to process notification-$/cancelRequest on Thread 14792
debug: (server): Took 0ms to process request-12813-textDocument/documentSymbol on Thread 14792
debug: (server): Took 0ms to process request-12812-textDocument/foldingRange on Thread 14792
debug: (server): Took 829ms to process request-12811-textDocument/codeAction on Thread 16892
debug: (server): Took 1243ms to process request-12814-textDocument/codeAction on Thread 23452
debug: (server): Took 1655ms to process request-12816-textDocument/codeAction on Thread 23236
debug: (server): Took 0ms to process notification-textDocument/didChange on Thread 14792
debug: (server): Took 0ms to process notification-$/cancelRequest on Thread 16892
debug: (server): Took 0ms to process notification-$/cancelRequest on Thread 23452
(... etc ...)

xydone avatar Dec 01 '24 13:12 xydone

Could you try adding "zig.zls.preferAstCheckAsChildProcess": false, to your settings and see if that makes a difference? If not, remove the "zig.path": "zig" setting so that ZLS doesn't use Zig. That should help to nail down the cause of this issue.

Could you also post the entire ZLS log output. The first few messages contains some useful information.

Techatrix avatar Dec 01 '24 13:12 Techatrix

Just gave "zig.zls.preferAstCheckAsChildProcess": false, a try and I am not able to replicate it at the moment. If it comes up again, I will post more info, but it's looking good for now.

edit: update from a day later, this indeed has fixed the issue. thanks! I am leaving the issue open in case you want any more information about the problem as to narrow down the root of the cause.

xydone avatar Dec 01 '24 14:12 xydone