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

[Neovim] Heavy CPU usage by fseventsd daemon and also LSP not working #1878

Closed
ghost opened this issue Feb 4, 2023 · 4 comments
Closed

[Neovim] Heavy CPU usage by fseventsd daemon and also LSP not working #1878

ghost opened this issue Feb 4, 2023 · 4 comments

Comments

@ghost
Copy link

ghost commented Feb 4, 2023

How are you using the lua-language-server?

NeoVim

Which OS are you using?

MacOS

What is the issue affecting?

Type Checking, Completion, Diagnostics/Syntax Checking, Other

Expected Behaviour

My understanding is that the fseventsd daemon should run within 1%. Below is how it works in the background without running lua-language-server.

image

The LSP server should work flawlessly: displaying diagnostic data, text completion, type checking.

Actual Behaviour

For some unknown reason, having recently upgraded to version lua-language-server 3.6.7, and later to version 3.6.8, the fseventsd daemon began to heavily load the processor, as well as lua-language-server. As far as I understand, there is intensive data logging. Because of all this, the laptop is incredibly noisy and heated.

image

At the same time, lua-language-server does not work in any way: it does not show diagnostics, autocompletion does not work, and there is no type checking.

In order to stop processes, you must first stop lua-language-server and then fseventsd, otherwise fseventsd will start working at full capacity again.

Reproduction steps

As already mentioned, it all started, sort of like with version lua-language-server 3.6+, lua has to work infrequently, but I can say for sure that this happened to me on versions 3.6.7 and 3.6.8.

I tried to solve the problem by reinstalling lua-language-server, but as you can see, it didn't help much:

  • reinstalled using Homebrew: brew uninstall lua-language-server and brew install lua-language-server
  • reinstalled via portable package manager for Neovim Mason using commands: :MasonUninstall lua-language-server and :MasonInstall lua-language-server

Setting lua-language-server in the configuration file lspconfig.lua is as follows:

local status, nvim_lsp = pcall(require, "lspconfig")
if (not status) then return end

nvim_lsp.sumneko_lua.setup {
  settings = {
    Lua = {
      runtime = {
        -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
        version = 'LuaJIT',
      },
      diagnostics = {
        -- Get the language server to recognize the `vim` global
        globals = {'vim'},
      },
      workspace = {
        -- Make the server aware of Neovim runtime files
        library = vim.api.nvim_get_runtime_file("", true),
      },
      -- Do not send telemetry data containing a randomized but unique identifier
      telemetry = {
        enable = false,
      },
    },
  },
}

Additional Notes

I have a MacBook Air 13 2019' with the following settings:

  • Processor Architecture: x86_64
  • System Version: macOS 13.2 (22D49)

Neovim version:

> nvim --version
NVIM v0.8.3
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@Ventura

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.8.3/share/nvim"

Run :checkhealth for more inf

Log File

I checked the performance of LSP servers using the built-in :checkhealth utility, the result was saved in the file /Users/dex/.local/state/nvim/lsp.log :

[ERROR][2022-11-09 13:33:47] .../vim/lsp/rpc.lua:733	"rpc"	"lua-language-server"	"stderr"	"script/core/completion/completion.lua:2240: attempt to call a nil value (field 'pause')\nstack traceback:\n\tscript/core/completion/completion.lua:2240: in function 'core.completion.completion.completion'\n\tscript/provider/provider.lua:588: in function <script/provider/provider.lua:552>\n\t[C]: in function 'xpcall'\n\tscript/proto/proto.lua:184: in function <script/proto/proto.lua:159>\n"
[ERROR][2022-11-09 13:33:48] .../vim/lsp/rpc.lua:733	"rpc"	"lua-language-server"	"stderr"	"script/core/completion/completion.lua:2240: attempt to call a nil value (field 'pause')\nstack traceback:\n\tscript/core/completion/completion.lua:2240: in function 'core.completion.completion.completion'\n\tscript/provider/provider.lua:588: in function <script/provider/provider.lua:552>\n\t[C]: in function 'xpcall'\n\tscript/proto/proto.lua:184: in function <script/proto/proto.lua:159>\n"
...
@rockyzhang24
Copy link

rockyzhang24 commented Feb 5, 2023

Seems same issue with mine (#1872). You could check it for your reference.

At the same time, lua-language-server does not work in any way: it does not show diagnostics, autocompletion does not work, and there is no type checking

It is because library = vim.api.nvim_get_runtime_file("", true) was added to workspace. It outputs a large bunch of directories for the server to scan. If you keep waiting (like a couple of minutes), all the functions will work after the server finishes scanning and its initialization. The author is now trying to fix it and so far it gets improved a lot by the latest commit (you could build it to test by yourself).

@ghost
Copy link
Author

ghost commented Feb 6, 2023

Thank you so much for your advice, @rockyzhang24. Indeed, if you comment out the lines of code belonging to workspace, then lua-language-server will start working normally, as before. I also added the line Lua.workspace.checkThirdParty = false to myself so that there is no annoying setup warning like in luassert.

Just in case, I made 2 log files:

  1. Normal log file with Lua.workspace: https://gist.github.com/H0rsefly/7f2119f5f3562ffe42fe16b35cfd4e47
  2. Log file without Lua.workspace: https://gist.github.com/H0rsefly/cf4dc99cab32bf0699fe0d82c47b9210

On your advice, I cloned the latest version of the main branch and tested it on commit 6c422b0. In this case, workspace starts up instantly, thanks to @sumneko. Now fseventsd daemon with lua-language-server no longer use my CPU.

I also made log files, you never know they will come in handy:

  1. Normal log file with Lua.workspace: https://gist.github.com/H0rsefly/880a9a300dc703d1bee6f3f6e7b8d15e
  2. Log file without Lua.workspace: https://gist.github.com/H0rsefly/e0629af3cfb80e559e9316d567d9dc16

@rockyzhang24
Copy link

My pleasure. You could try if the newest version 3.6.10 has fixed this issue. It works like a charm on my side. With the whole neovim runtime set to workspace.library, it just takes about a couple of seconds to finish scanning and initialization.

@ghost
Copy link
Author

ghost commented Feb 7, 2023

Perfect! Indeed, with version 3.6.10 everything works flawlessly. Thanks again for your help and explanations, you helped me a lot.

@ghost ghost closed this as completed Feb 7, 2023
This issue was closed.
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

1 participant