efm-langserver icon indicating copy to clipboard operation
efm-langserver copied to clipboard

Multiple jobs overloading the cpu

Open cinghiopinghio opened this issue 4 years ago • 8 comments

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
    }
}

cinghiopinghio avatar Feb 26 '21 08:02 cinghiopinghio

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.

sevanteri avatar Mar 30 '21 07:03 sevanteri

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.

cinghiopinghio avatar Mar 30 '21 07:03 cinghiopinghio

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?

sevanteri avatar Mar 30 '21 12:03 sevanteri

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.

image

My efm config: https://github.com/ecosse3/nvim/tree/master/lua/lsp/efm

Anyone experiences similar issue?

ecosse3 avatar Apr 01 '21 07:04 ecosse3

Setting settings.lintDebounce = 1000 solved 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 avatar Apr 01 '21 12:04 sevanteri

@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:
    ...

AckslD avatar Jun 09 '21 12:06 AckslD

Should the setting be just in the root level of the settings?

Yes, the root level is the correct place.

sevanteri avatar Jun 10 '21 07:06 sevanteri

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?

yujinyuz avatar Jun 21 '21 04:06 yujinyuz