efm-langserver
efm-langserver copied to clipboard
Multiple jobs overloading the cpu
Thanks for this interesting project.
I would like to use it with pylint for python in neovim (with its builtin client).
Unfortunately if I make many changes to the file (like deleting multiple chars) many jobs get spawned eating up the cpu very fast (I have 8 threads). This means that deleting 20 chars produce 20 jobs that could last for a minute or two globally. Also all other tasks become slow as the cpu s clogged.
I'm aware of this PR https://github.com/mattn/efm-langserver/pull/82 but it seem that it's not working for me. Maybe the reason is that all jobs are running somehow and not waiting in any queue.
This is the relevant configuration I'm providing to the language server:
lspconfig.efm.setup {
cmd = {"efm-langserver", "-logfile", "/home/xxxxx/efm.log"},
on_attach = on_attach,
filetypes = {'python'},
root_dir = lspconfig.util.root_pattern(".git/", ".bashrc"),
settings = {
rootMarkers = {".git/", ".bashrc"},
languages = {
python = {
{
lintCommand = "pylint -j 1 --from-stdin ${INPUT} --score no --msg-template '{path}:{line}:{column}:{C} {msg_id} {msg} ({symbol}) -- PL' | sed -e 's/:I\\s/:H /' -e 's/:[CR]\\s/:I /' -e '/C0103/d'",
lintIgnoreExitCode = true,
lintStdin = true,
lintDebounce = 5,
lintFormats = {"%f:%l:%c:%t %m"},
onSave = true,
},
},
},
},
diagnostics = {
onChange = false
}
}
I just ran into this same problem with python and flake8. For me, it would be enough to run flake8 only when leaving insert mode.
TBH, I realized that the situation get better when carefully restricting the root folder to the local folder as in:
root_dir = lspconfig.util.root_pattern(".git/", ".bashrc", "README.md", "."),
Unfortunately, even with this fix, the issue arise when typing on a comment string. It may be a problem of the neovim client.
Setting settings.lintDebounce = 1000 solved this for me.
It seems like the last linter canceling from PR #82 isn't working as supposed to, maybe. I put some logging around the canceling code and could see it being called but the flake8 processes still flooded in.
But then again I also see lintRequest being called waaay to many times, so maybe nvim is sending some events too many times?
efm-langserver almost crashing my system and whole neovim is unusable due to high CPU usage. I'm using efm to make eslint_d and prettier work.

My efm config: https://github.com/ecosse3/nvim/tree/master/lua/lsp/efm
Anyone experiences similar issue?
Setting
settings.lintDebounce = 1000solved this for me.
Want to correct myself a bit. I had configured efm through the yaml file first, where setting lint-debounce: 1s was the solution.
But now I've configured efm throught nvim lspconfig setup. Giving 1000 for lintDebounce was not enough. Just logged the debounce timer a bit and 1000 is not 1 second, but 1000000000 is. So it's nano seconds you have to input to lintDebounce
@sevanteri I tried your suggestion but still getting mad cpu and ram uses from flake8 sometimes. Should the setting be just in the root level of the settings?
version: 2
lint-debounce: 1s # to avoid cpu mayhem
tools:
...
Should the setting be just in the root level of the settings?
Yes, the root level is the correct place.
Should the setting be just in the root level of the settings?
Yes, the root level is the correct place.
Would it still work if I only have this in my settings
version: 2
lint-debounce: 1s
and then configure everything else via lua config?