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

Occasional huge non-GC stutters when saving files with rust-analyzer #4342

Open
3 tasks done
snyball opened this issue Feb 21, 2024 · 0 comments
Open
3 tasks done

Occasional huge non-GC stutters when saving files with rust-analyzer #4342

snyball opened this issue Feb 21, 2024 · 0 comments
Labels

Comments

@snyball
Copy link

snyball commented Feb 21, 2024

Thank you for the bug report

  • I am using the latest version of lsp-mode related packages.
  • I checked FAQ and Troubleshooting sections
  • You may also try reproduce the issue using clean environment using the following command: M-x lsp-start-plain

Bug description

I've nailed it down to lsp--text-document-did-save, which seems to be blocking occasionally, sometimes it takes as long as a couple of seconds. I've confirmed that it's not caused by the GC kicking in, by testing with (setq garbage-collection-messages t)

Steps to reproduce

  • M-x lsp-start-plain
  • Open a Rust file in a medium-sized (>10000LOC) project with lsp-mode
  • Repeatedly make small changes and save
  • You may have to repeat these steps tens of times before seeing a stutter

The stutters vary in length, from hundreds to thousands of milliseconds.

Expected behavior

I expected lsp--text-document-did-save to not block.

My hunch is that rust-analyzer occasionally takes a long time to process the didChange message, and will block when processing other input during this time. If a blocking lsp-mode call comes shortly after the non-blocking lsp--text-document-did-save, then that other synchronous call will be blocking the UI, when it would usually be quick. This explains the inconsistent behavior, as it would depend on when the various timers are triggered.

I don't observe this behavior with e.g Zig zls.

If that's the case, one simple hack would be to just stagger those timers after lsp--text-document-did-save, but this is obviously both not robust, and introduces an arbitrary delay to LSP feedback whenever a file is saved (perhaps unnecessarily if rust-analyzer processed the didChange request quickly.)

Which Language Server did you use?

rust-analyzer

OS

Linux

Error callstack

No response

Anything else?

No response

@snyball snyball added the bug label Feb 21, 2024
@snyball snyball changed the title Occasional huge stutters when saving files with rust-analyzer Occasional huge non-GC stutters when saving files with rust-analyzer Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant