nix-community / rnix-lsp

WIP Language Server for Nix! [maintainer=@aaronjanse]
MIT License
701 stars 41 forks source link

on very large files emacs becomes unresponsive #62

Open NobbZ opened 2 years ago

NobbZ commented 2 years ago

Describe the bug

Emacs becomes unresponsive when large files are opened.

Steps to reproduce

Steps to reproduce the behavior:

  1. Open pkgs/top-level/all-packages.nix with the rnix lsp enabled

Expected behavior

Emacs remains responsive

Additional context

Editor configuration is generated by HM, and spread across several modules which generate several emacs packages which are then loaded on start.

The most relevant configuration for rnix-lsp is probably to be found in:

https://github.com/NobbZ/nixos-config/blob/afd01c05fd8cc81b62d55635cd5aa5fbebae0ae0/home/modules/languages/nix/default.nix

aaronjanse commented 2 years ago

Thank you for the Nix expression! :-)

That'll make things much easier to reproduce, since this seems to be working for me without an issue in my dev environment

NobbZ commented 2 years ago

I just checked HTOP, and it seems as if just emacs is going to hog a single CPU, the LSP though doesn't appear to consume any mentionable resources… Its there at 0.1% CPU and ~20k of RES memory.

Though if I manage to kill the LSP using M-x lsp-workspace-shutdown RET emacs becomes responsive again and I can browse the file and operate emacs normally.

If I temporarily blacklist my local nixpkgs clone and open the mentioned file again, there are also no issues, as soon as I start the LSP manually, emacs is unresponsive again.

Perhaps something in lsp-mode that might cause this behaviour due to too large responses?

kira-bruneau commented 2 years ago

I've definitely noticed a slowdown (especially on pkgs/top-level/all-packages.nix) since the change that adds links on paths. I'm not sure if that's related?

Ma27 commented 2 years ago

Not an emacs expert, but it seems as if the issue can be mitigated by declaring e.g. (setq lsp-idle-delay 0.500) (see https://emacs-lsp.github.io/lsp-mode/page/performance/). Would you mind checking if that's the case?

As a next step I'd try to narrow down what the actual problem is (though the link-path thing is rather likely then) and evaluate possible solution (such as only evaluating a subset of all link-paths).

flurie commented 2 years ago

I've been having this issue on macOS as well. I've taken to editing all-packages.nix in vim as a stopgap.

Setting lsp-idle-delay to 0.5 does not seem to mitigate the issue enough to make it usable with all-packages.nix.