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 lsp client stuck on CPU 100% / a very high CPU usage with big files #14037

Closed
ttys3 opened this issue Mar 1, 2021 · 18 comments
Closed
Labels
bug issues reporting wrong behavior lsp

Comments

@ttys3
Copy link

ttys3 commented Mar 1, 2021

  • nvim --version:
NVIM v0.5.0-dev+1115-gc1fbc2ddf
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/ttys3/.config/nvim/neovim/build/config -I/home/ttys3/.config/nvim/neovim/src -I/home/ttys3/.config/nvim/neovim/.deps/usr/include -I/usr/include -I/home/ttys3/.config/nvim/neovim/build/src/nvim/auto -I/home/ttys3/.config/nvim/neovim/build/include
Compiled by ttys3@ttys3-ht

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

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

Run :checkhealth for more info
  • language server name/version:

gopls version v0.6.6

  • Operating system/version:

Ubuntu 20.10 x86_64

nvim -c ":checkhealth nvim lspconfig"
health#nvim#check
========================================================================
## Configuration
  - OK: no issues found

## Performance
  - OK: Build type: RelWithDebInfo

## Remote Plugins
  - OK: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=\177
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
  - INFO: $TERM_PROGRAM='tmux'
  - INFO: $COLORTERM='truecolor'

## tmux
  - OK: escape-time: 0
  - INFO: Checking stuff
  - OK: focus-events: on
  - INFO: $TERM: screen-256color

health#lspconfig#check
========================================================================
## Checking language server protocol configuration
  - INFO: pyright: configuration checked.
  - INFO: vimls: configuration checked.
  - INFO: vuels: configuration checked.
  - INFO: cssls: configuration checked.
  - INFO: yamlls: configuration checked.
  - INFO: jsonls: configuration checked.
  - INFO: bashls: configuration checked.
  - INFO: dockerls: configuration checked.
  - INFO: intelephense: configuration checked.
  - INFO: gopls: configuration checked.
  - INFO: tsserver: configuration checked.
  - INFO: rust_analyzer: configuration checked.
  - INFO: html: configuration checked.
  - INFO: clangd: configuration checked.
lsp.log

the log included the whole source code (I can not provide here because it is not open sourced code and I do not own the copyright), I removed the file content in the log

[ DEBUG ] 2021-03-01T10:06:14+0800 ] /usr/local/share/nvim/runtime/lua/vim/lsp/rpc.lua:492 ]	"decoded"	{  id = 25,  jsonrpc = "2.0",  result = {    isIncomplete = true,    items = { {        detail = "func(userIdList []uint32) []*ht_user_search.SearchUserItemResult",        filterText = "BuildDefaultSearchResByUserIdList",        insertTextFormat = 1,        kind = 2,        label = "BuildDefaultSearchResByUserIdList",        preselect = true,        sortText = "00000",        textEdit = {          newText = "BuildDefaultSearchResByUserIdList",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "*ClientSearchParams",        filterText = "this",        insertTextFormat = 1,        kind = 6,        label = "this",        sortText = "00001",        textEdit = {          newText = "this",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "[]uint32",        filterText = "userIdList",        insertTextFormat = 1,        kind = 6,        label = "userIdList",        sortText = "00002",        textEdit = {          newText = "userIdList",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "Age",        insertTextFormat = 1,        kind = 5,        label = "Age",        sortText = "00003",        textEdit = {          newText = "Age",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "uint32",        filterText = "BestMatchNum",        insertTextFormat = 1,        kind = 5,        label = "BestMatchNum",        sortText = "00004",        textEdit = {          newText = "BestMatchNum",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "uint32",        filterText = "BirthFrom",        insertTextFormat = 1,        kind = 5,        label = "BirthFrom",        sortText = "00005",        textEdit = {          newText = "BirthFrom",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "uint32",        filterText = "BirthTo",        insertTextFormat = 1,        kind = 5,        label = "BirthTo",        sortText = "00006",        textEdit = {          newText = "BirthTo",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "CacheKey",        insertTextFormat = 1,        kind = 5,        label = "CacheKey",        sortText = "00007",        textEdit = {          newText = "CacheKey",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "CityCdi",        insertTextFormat = 1,        kind = 5,        label = "CityCdi",        sortText = "00008",        textEdit = {          newText = "CityCdi",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "bool",        filterText = "ConditionWithCity",        insertTextFormat = 1,        kind = 5,        label = "ConditionWithCity",        sortText = "00009",        textEdit = {          newText = "ConditionWithCity",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "Country",        insertTextFormat = 1,        kind = 5,        label = "Country",        sortText = "00010",        textEdit = {          newText = "Country",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "int",        filterText = "Debug",        insertTextFormat = 1,        kind = 5,        label = "Debug",        sortText = "00011",        textEdit = {          newText = "Debug",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "Email",        insertTextFormat = 1,        kind = 5,        label = "Email",        sortText = "00012",        textEdit = {          newText = "Email",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "Lang",        insertTextFormat = 1,        kind = 5,        label = "Lang",        sortText = "00013",        textEdit = {          newText = "Lang",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "float32",        filterText = "Latitude",        insertTextFormat = 1,        kind = 5,        label = "Latitude",        sortText = "00014",        textEdit = {          newText = "Latitude",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "uint32",        filterText = "Learnlang",        insertTextFormat = 1,        kind = 5,        label = "Learnlang",        sortText = "00015",        textEdit = {          newText = "Learnlang",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "LearnlangStr",        insertTextFormat = 1,        kind = 5,        label = "LearnlangStr",        sortText = "00016",        textEdit = {          newText = "LearnlangStr",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "float32",        filterText = "Longitute",        insertTextFormat = 1,        kind = 5,        label = "Longitute",        sortText = "00017",        textEdit = {          newText = "Longitute",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "uint32",        filterText = "Nativelang",        insertTextFormat = 1,        kind = 5,        label = "Nativelang",        sortText = "00018",        textEdit = {          newText = "Nativelang",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "NativelangStr",        insertTextFormat = 1,        kind = 5,        label = "NativelangStr",        sortText = "00019",        textEdit = {          newText = "NativelangStr",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "Nickname",        insertTextFormat = 1,        kind = 5,        label = "Nickname",        sortText = "00020",        textEdit = {          newText = "Nickname",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "uint32",        filterText = "Page",        insertTextFormat = 1,        kind = 5,        label = "Page",        sortText = "00021",        textEdit = {          newText = "Page",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "uint32",        filterText = "PageSize",        insertTextFormat = 1,        kind = 5,        label = "PageSize",        sortText = "00022",        textEdit = {          newText = "PageSize",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "bool",        filterText = "PoliticsCheck",        insertTextFormat = 1,        kind = 5,        label = "PoliticsCheck",        sortText = "00023",        textEdit = {          newText = "PoliticsCheck",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "uint32",        filterText = "RealLearnLang",        insertTextFormat = 1,        kind = 5,        label = "RealLearnLang",        sortText = "00024",        textEdit = {          newText = "RealLearnLang",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "ReqSource",        insertTextFormat = 1,        kind = 5,        label = "ReqSource",        sortText = "00025",        textEdit = {          newText = "ReqSource",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "uint32",        filterText = "ReqTs",        insertTextFormat = 1,        kind = 5,        label = "ReqTs",        sortText = "00026",        textEdit = {          newText = "ReqTs",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "[]uint32",        filterText = "SearchLevel",        insertTextFormat = 1,        kind = 5,        label = "SearchLevel",        sortText = "00027",        textEdit = {          newText = "SearchLevel",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "Sex",        insertTextFormat = 1,        kind = 5,        label = "Sex",        sortText = "00028",        textEdit = {          newText = "Sex",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "Skilllevel",        insertTextFormat = 1,        kind = 5,        label = "Skilllevel",        sortText = "00029",        textEdit = {          newText = "Skilllevel",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "SkilllevelRange",        insertTextFormat = 1,        kind = 5,        label = "SkilllevelRange",        sortText = "00030",        textEdit = {          newText = "SkilllevelRange",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "Sort",        insertTextFormat = 1,        kind = 5,        label = "Sort",        sortText = "00031",        textEdit = {          newText = "Sort",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "int",        filterText = "Terminaltype",        insertTextFormat = 1,        kind = 5,        label = "Terminaltype",        sortText = "00032",        textEdit = {          newText = "Terminaltype",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "*common.SERedisCacheStruct",        filterText = "UserInfo",        insertTextFormat = 1,        kind = 5,        label = "UserInfo",        sortText = "00033",        textEdit = {          newText = "UserInfo",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "[]uint32",        filterText = "UserLearnLang",        insertTextFormat = 1,        kind = 5,        label = "UserLearnLang",        sortText = "00034",        textEdit = {          newText = "UserLearnLang",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "[]uint32",        filterText = "UserNativeLang",        insertTextFormat = 1,        kind = 5,        label = "UserNativeLang",        sortText = "00035",        textEdit = {          newText = "UserNativeLang",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "uint32",        filterText = "Userid",        insertTextFormat = 1,        kind = 5,        label = "Userid",        sortText = "00036",        textEdit = {          newText = "Userid",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "Username",        insertTextFormat = 1,        kind = 5,        label = "Username",        sortText = "00037",        textEdit = {          newText = "Username",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "Version",        insertTextFormat = 1,        kind = 5,        label = "Version",        sortText = "00038",        textEdit = {          newText = "Version",          range = {            end = {              character = 18,              line = 1684            },            start = {              character = 18,              line = 1684            }          }        }      } }  }}
[ DEBUG ] 2021-03-01T10:06:26+0800 ] /usr/local/share/nvim/runtime/lua/vim/lsp/rpc.lua:492 ]	"decoded"	{  jsonrpc = "2.0",  method = "window/logMessage",  params = {    message = "2021/03/01 10:06:13 background imports cache refresh starting\n",    type = 3  }}
[ DEBUG ] 2021-03-01T10:06:26+0800 ] /usr/local/share/nvim/runtime/lua/vim/lsp/rpc.lua:492 ]	"decoded"	{  jsonrpc = "2.0",  method = "window/logMessage",  params = {    message = "2021/03/01 10:06:15 background refresh finished after 1.948603469s\n",    type = 3  }}
[ DEBUG ] 2021-03-01T10:06:26+0800 ] /usr/local/share/nvim/runtime/lua/vim/lsp.lua:487 ]	"notification"	"window/logMessage"	{  message = "2021/03/01 10:06:13 background imports cache refresh starting\n",  type = 3}
[ DEBUG ] 2021-03-01T10:06:26+0800 ] /usr/local/share/nvim/runtime/lua/vim/lsp/handlers.lua:407 ]	"default_handler"	"window/logMessage"	{  client_id = 1,  params = {    message = "2021/03/01 10:06:13 background imports cache refresh starting\n",    type = 3  }}
[ INFO ] 2021-03-01T10:06:26+0800 ] /usr/local/share/nvim/runtime/lua/vim/lsp/handlers.lua:379 ]	"2021/03/01 10:06:13 background imports cache refresh starting\n"
[ DEBUG ] 2021-03-01T10:06:26+0800 ] /usr/local/share/nvim/runtime/lua/vim/lsp/rpc.lua:492 ]	"decoded"	{  id = 26,  jsonrpc = "2.0",  result = {}}
[ DEBUG ] 2021-03-01T10:06:26+0800 ] /usr/local/share/nvim/runtime/lua/vim/lsp/rpc.lua:492 ]	"decoded"	{  id = 27,  jsonrpc = "2.0",  result = {    isIncomplete = true,    items = { {        detail = "func(userIdList []uint32) []*ht_user_search.SearchUserItemResult",        filterText = "BuildDefaultSearchResByUserIdList",        insertTextFormat = 1,        kind = 2,        label = "BuildDefaultSearchResByUserIdList",        preselect = true,        sortText = "00000",        textEdit = {          newText = "BuildDefaultSearchResByUserIdList",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "*ClientSearchParams",        filterText = "this",        insertTextFormat = 1,        kind = 6,        label = "this",        sortText = "00001",        textEdit = {          newText = "this",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "[]uint32",        filterText = "userIdList",        insertTextFormat = 1,        kind = 6,        label = "userIdList",        sortText = "00002",        textEdit = {          newText = "userIdList",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "Age",        insertTextFormat = 1,        kind = 5,        label = "Age",        sortText = "00003",        textEdit = {          newText = "Age",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "uint32",        filterText = "BestMatchNum",        insertTextFormat = 1,        kind = 5,        label = "BestMatchNum",        sortText = "00004",        textEdit = {          newText = "BestMatchNum",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "uint32",        filterText = "BirthFrom",        insertTextFormat = 1,        kind = 5,        label = "BirthFrom",        sortText = "00005",        textEdit = {          newText = "BirthFrom",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "uint32",        filterText = "BirthTo",        insertTextFormat = 1,        kind = 5,        label = "BirthTo",        sortText = "00006",        textEdit = {          newText = "BirthTo",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "CacheKey",        insertTextFormat = 1,        kind = 5,        label = "CacheKey",        sortText = "00007",        textEdit = {          newText = "CacheKey",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "CityCdi",        insertTextFormat = 1,        kind = 5,        label = "CityCdi",        sortText = "00008",        textEdit = {          newText = "CityCdi",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "bool",        filterText = "ConditionWithCity",        insertTextFormat = 1,        kind = 5,        label = "ConditionWithCity",        sortText = "00009",        textEdit = {          newText = "ConditionWithCity",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "Country",        insertTextFormat = 1,        kind = 5,        label = "Country",        sortText = "00010",        textEdit = {          newText = "Country",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "int",        filterText = "Debug",        insertTextFormat = 1,        kind = 5,        label = "Debug",        sortText = "00011",        textEdit = {          newText = "Debug",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "Email",        insertTextFormat = 1,        kind = 5,        label = "Email",        sortText = "00012",        textEdit = {          newText = "Email",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "Lang",        insertTextFormat = 1,        kind = 5,        label = "Lang",        sortText = "00013",        textEdit = {          newText = "Lang",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "float32",        filterText = "Latitude",        insertTextFormat = 1,        kind = 5,        label = "Latitude",        sortText = "00014",        textEdit = {          newText = "Latitude",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "uint32",        filterText = "Learnlang",        insertTextFormat = 1,        kind = 5,        label = "Learnlang",        sortText = "00015",        textEdit = {          newText = "Learnlang",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "LearnlangStr",        insertTextFormat = 1,        kind = 5,        label = "LearnlangStr",        sortText = "00016",        textEdit = {          newText = "LearnlangStr",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "float32",        filterText = "Longitute",        insertTextFormat = 1,        kind = 5,        label = "Longitute",        sortText = "00017",        textEdit = {          newText = "Longitute",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "uint32",        filterText = "Nativelang",        insertTextFormat = 1,        kind = 5,        label = "Nativelang",        sortText = "00018",        textEdit = {          newText = "Nativelang",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "NativelangStr",        insertTextFormat = 1,        kind = 5,        label = "NativelangStr",        sortText = "00019",        textEdit = {          newText = "NativelangStr",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "Nickname",        insertTextFormat = 1,        kind = 5,        label = "Nickname",        sortText = "00020",        textEdit = {          newText = "Nickname",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "uint32",        filterText = "Page",        insertTextFormat = 1,        kind = 5,        label = "Page",        sortText = "00021",        textEdit = {          newText = "Page",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "uint32",        filterText = "PageSize",        insertTextFormat = 1,        kind = 5,        label = "PageSize",        sortText = "00022",        textEdit = {          newText = "PageSize",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "bool",        filterText = "PoliticsCheck",        insertTextFormat = 1,        kind = 5,        label = "PoliticsCheck",        sortText = "00023",        textEdit = {          newText = "PoliticsCheck",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "uint32",        filterText = "RealLearnLang",        insertTextFormat = 1,        kind = 5,        label = "RealLearnLang",        sortText = "00024",        textEdit = {          newText = "RealLearnLang",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "ReqSource",        insertTextFormat = 1,        kind = 5,        label = "ReqSource",        sortText = "00025",        textEdit = {          newText = "ReqSource",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "uint32",        filterText = "ReqTs",        insertTextFormat = 1,        kind = 5,        label = "ReqTs",        sortText = "00026",        textEdit = {          newText = "ReqTs",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "[]uint32",        filterText = "SearchLevel",        insertTextFormat = 1,        kind = 5,        label = "SearchLevel",        sortText = "00027",        textEdit = {          newText = "SearchLevel",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "Sex",        insertTextFormat = 1,        kind = 5,        label = "Sex",        sortText = "00028",        textEdit = {          newText = "Sex",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "Skilllevel",        insertTextFormat = 1,        kind = 5,        label = "Skilllevel",        sortText = "00029",        textEdit = {          newText = "Skilllevel",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "SkilllevelRange",        insertTextFormat = 1,        kind = 5,        label = "SkilllevelRange",        sortText = "00030",        textEdit = {          newText = "SkilllevelRange",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "Sort",        insertTextFormat = 1,        kind = 5,        label = "Sort",        sortText = "00031",        textEdit = {          newText = "Sort",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "int",        filterText = "Terminaltype",        insertTextFormat = 1,        kind = 5,        label = "Terminaltype",        sortText = "00032",        textEdit = {          newText = "Terminaltype",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "*common.SERedisCacheStruct",        filterText = "UserInfo",        insertTextFormat = 1,        kind = 5,        label = "UserInfo",        sortText = "00033",        textEdit = {          newText = "UserInfo",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "[]uint32",        filterText = "UserLearnLang",        insertTextFormat = 1,        kind = 5,        label = "UserLearnLang",        sortText = "00034",        textEdit = {          newText = "UserLearnLang",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "[]uint32",        filterText = "UserNativeLang",        insertTextFormat = 1,        kind = 5,        label = "UserNativeLang",        sortText = "00035",        textEdit = {          newText = "UserNativeLang",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "uint32",        filterText = "Userid",        insertTextFormat = 1,        kind = 5,        label = "Userid",        sortText = "00036",        textEdit = {          newText = "Userid",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "Username",        insertTextFormat = 1,        kind = 5,        label = "Username",        sortText = "00037",        textEdit = {          newText = "Username",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      }, {        detail = "string",        filterText = "Version",        insertTextFormat = 1,        kind = 5,        label = "Version",        sortText = "00038",        textEdit = {          newText = "Version",          range = {            end = {              character = 21,              line = 1684            },            start = {              character = 21,              line = 1684            }          }        }      } }  }}
[ DEBUG ] 2021-03-01T10:06:26+0800 ] /usr/local/share/nvim/runtime/lua/vim/lsp.lua:487 ]	"notification"	"window/logMessage"	{  message = "2021/03/01 10:06:15 background refresh finished after 1.948603469s\n",  type = 3}
[ DEBUG ] 2021-03-01T10:06:26+0800 ] /usr/local/share/nvim/runtime/lua/vim/lsp/handlers.lua:407 ]	"default_handler"	"window/logMessage"	{  client_id = 1,  params = {    message = "2021/03/01 10:06:15 background refresh finished after 1.948603469s\n",    type = 3  }}
[ INFO ] 2021-03-01T10:06:26+0800 ] /usr/local/share/nvim/runtime/lua/vim/lsp/handlers.lua:379 ]	"2021/03/01 10:06:15 background refresh finished after 1.948603469s\n"

Steps to reproduce

init.vim:

" Specify a directory for plugins
" - For Neovim: ~/.local/share/nvim/plugged
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.local/share/nvim/plugged')

set nu

Plug 'neovim/nvim-lspconfig'
autocmd Filetype go setlocal omnifunc=v:lua.vim.lsp.omnifunc

" https://github.com/nvim-lua/completion-nvim/wiki/chain-complete-support
Plug 'nvim-lua/completion-nvim'

" Initialize plugin system
call plug#end()

" Configure the completion chains
let g:completion_chain_complete_list = {
    \ 'default': [
    \    {'complete_items': ['lsp']},
    \    {'mode': '<c-p>'},
    \    {'mode': '<c-n>'}
    \]
\}

let g:completion_enable_auto_popup = 1
let g:completion_enable_auto_hover = 1
let g:completion_enable_auto_signature = 1
let g:completion_matching_smart_case = 1
let g:completion_trigger_keyword_length = 1 " default = 1
let g:completion_timer_cycle = 80 "default value is 80
" auto change sources whenever this completion source has no complete item
let g:completion_auto_change_source = 1
let g:completion_enable_auto_paren = 1

" Set completeopt to have a better completion experience
set completeopt=menuone,noinsert,noselect
" Avoid showing message extra message when using completion
set shortmess+=c


" The delay is governed by vim's updatetime option,
" default updatetime 4000ms is not good for async update
set updatetime=100

" set signcolumn to 2 to avoid git gutter sign conflict with linter sign
set signcolumn=yes:2

lua << EOF

local lsp = require'lspconfig'
local cmp = require'completion'


--@param client: (required, vim.lsp.client)
local mix_attach = function(client)
  -- lsp_status.on_attach(client)
  cmp.on_attach(client)
end

-- lsp.gopls.setup{}
-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/gopls.lua
-- https://github.com/golang/tools/blob/master/gopls/doc/vim.md#neovim
-- https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#gopls
lsp.gopls.setup({
  on_attach = mix_attach,
  settings = {
    gopls = {
      usePlaceholders = true,
      completeUnimported = true,
    },
  },
})

EOF
  1. open a go file under a regular go project, the file must be big, about 3000 lines code

the golang source code I used to re-produce the issue:

(clone the whole repo https://github.com/blevesearch/bleve, and replace the go file analysis/lang/fr/light_stemmer_fr_test.go with this one: https://gist.github.com/ttys3/a0fd236ebff873204927f090f84a33fe/raw/77067a8b477071e929cfa6cc3f911cc2665930ff/light_stemmer_fr_test.go )

this file has about 4KB size, and about 1124 lines.

  1. open the modified analysis/lang/fr/light_stemmer_fr_test.go, goto line 1123, type // and then type single char x fast as you can. (do not type too slow, and then neovim lsp client will continue to send the whole file to lsp server)

  2. neovim cpu will 100%

  3. disable lsp and lsp auto completion, the problem did not occurred

Actual behaviour

neovim stuck on CPU 100% and for minutes it can not handle anything

I symlinked neovim to vi so that I could execute it fast(only two chars to enter), don't confused by the executable name vi

image

Expected behaviour

auto completion works without no explicit stop time

FAQ

Q: why do you write comments like this ? ( // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx )

A: this is just a file I want to show the issue.
because I could not provide the real file (about 2k lines) here.
yes, no one will write comments like this. or coding fast like this.

I encountered the issue in the real life with a source file about 2k lines code, and typing with slow and normal speed, the CPU goes 100%. ( and this is why I created the issue. I can not use neovim to do the job with a big file. my cursor just can not move with CPU 100% )

@mjlbach
Copy link
Contributor

mjlbach commented Mar 4, 2021

Can you reproduce this without completion.nvim (with omnifunc)? Otherwise this belongs on the completion.nvim tracker, and I would encourage you to try out https://github.com/hrsh7th/nvim-compe

@ttys3
Copy link
Author

ttys3 commented Mar 8, 2021

@mjlbach after disable completion-nvim but only enable omnifunc.

(and I also disabled other lsp related plugins)

The problem still persists

the log (too long, can not post here):

image

@ttys3
Copy link
Author

ttys3 commented Mar 8, 2021

After I disabled vim-illuminate (has textDocument/documentHighlight performance problem) plugin, and also the kosayoda/nvim-lightbulb (has textDocument/codeAction performance problem) these two plugin also has performance problem.

and nvim lsp continue can stuck on CPU 100%

so I check the log, and edit neovim runtome file: runtime/lua/vim/lsp.lua
on line 872, I just removed the call client.notify("textDocument/didChange" ...

Things have changed.

the golang source code I used to re-produce the issue:

(clone the whole repo https://github.com/blevesearch/bleve, and replace the go file analysis/lang/fr/light_stemmer_fr_test.go with this one: https://gist.github.com/ttys3/a0fd236ebff873204927f090f84a33fe/raw/77067a8b477071e929cfa6cc3f911cc2665930ff/light_stemmer_fr_test.go )

this file has about 4KB size, and about 1124 lines. (if we use a 3000 lines source file, the result will be more obvious)

open the modified analysis/lang/fr/light_stemmer_fr_test.go, goto line 1123, type // and then type single char x fast as you can.

neovim-lsp-textDocument-didChange-problem-Peek 2021-03-08 23-17

even I disabled client.notify("textDocument/didChange" ... call, nvim lsp performance still need imporve, see the gif:

Peek 2021-03-08 23-22

and last, my hardware:

❯ neofetch
          /:-------------:\          ttys3@fedora
       :-------------------::        ------------
     :-----------/shhOHbmp---:\      OS: Fedora 33 (Workstation Edition) x86_64
   /-----------omMMMNNNMMD  ---:     Kernel: 5.10.19-200.fc33.x86_64
  :-----------sMMMMNMNMP.    ---:    Uptime: 1 hour, 30 mins
 :-----------:MMMdP-------    ---\   Packages: 2962 (rpm), 23 (flatpak)
,------------:MMMd--------    ---:   Shell: zsh 5.8
:------------:MMMd-------    .---:   Resolution: 3840x2160
:----    oNMMMMMMMMMNho     .----:   DE: GNOME 3.38.3
:--     .+shhhMMMmhhy++   .------/   WM: Mutter
:-    -------:MMMd--------------:    WM Theme: Adwaita
:-   --------/MMMd-------------;     Theme: Adwaita [GTK2/3]
:-    ------/hMMMy------------:      Icons: Adwaita [GTK2/3]
:-- :dMNdhhdNMMNo------------;       Terminal: tmux
:---:sdNMMMMNds:------------:        CPU: Intel i7-8700K (12) @ 4.700GHz
:------:://:-------------::          GPU: Intel CometLake-S GT2 [UHD Graphics 630]
:---------------------://            GPU: NVIDIA GeForce GTX 1060 3GB
                                     Memory: 10467MiB / 31528MiB

@ttys3
Copy link
Author

ttys3 commented Mar 8, 2021

While neovim is CPU 100% and stuck, if I kill neovim with SIGTERM in htop(or use kill -9 pidof nvim), I can see lots of these errors:

Error detected while processing VimLeavePre Autocommands for "*":
Error executing vim.schedule lua callback: /usr/local/share/nvim/runtime/lua/vim/treesitter/query.lua:135:
 bad argument #1 to 'get_node_text' (string expected, got nil)
Error executing vim.schedule lua callback: /usr/local/share/nvim/runtime/lua/vim/treesitter/query.lua:135:
 bad argument #1 to 'get_node_text' (string expected, got nil)
Error executing vim.schedule lua callback: /usr/local/share/nvim/runtime/lua/vim/treesitter/query.lua:135:
 bad argument #1 to 'get_node_text' (string expected, got nil)
Error executing vim.schedule lua callback: /usr/local/share/nvim/runtime/lua/vim/treesitter/query.lua:135:
 bad argument #1 to 'get_node_text' (string expected, got nil)
-- More --

@mjlbach
Copy link
Contributor

mjlbach commented Mar 8, 2021

Can you reproduce this with a minimal config? That's a tree-sitter error. You can use this with modifications to work for gopls.

@glepnir
Copy link
Member

glepnir commented Mar 10, 2021

I can't reproduce this issue.

image

@ttys3
Copy link
Author

ttys3 commented Mar 10, 2021

@glepnir I think my description to re-produce the issue is not clear.

I tried again use the init.vim I provided above, the issue is a 100% re-produce-able

I re-edited the description above and make it clear:

the golang source code I used to re-produce the issue:

(clone the whole repo https://github.com/blevesearch/bleve, and replace the go file analysis/lang/fr/light_stemmer_fr_test.go with this one: https://gist.github.com/ttys3/a0fd236ebff873204927f090f84a33fe/raw/77067a8b477071e929cfa6cc3f911cc2665930ff/light_stemmer_fr_test.go )

this file has about 4KB size, and about 1124 lines. (if we use a 3000 lines source file, the result will be more obvious)

open the modified analysis/lang/fr/light_stemmer_fr_test.go, goto line 1123, type // and then type single char x fast as you can.

  1. you can not type too slow in order to show this issue more obviously

Peek 2021-03-11 00-04

the simple x char repeat is just for re-produce the issue.
I encountered the issue in the real life with a source file about 2k lines code, and typing with slow and normal speed, the CPU goes 100%. ( and this is why I created the issue. I can not use neovim to do the job with a big file. my cursor just can not move with CPU 100% )

and also, thank you @mjlbach, I'll try the minimal_init.lua config later

@glepnir
Copy link
Member

glepnir commented Mar 10, 2021

cannot reproduce… I used same file

@ttys3
Copy link
Author

ttys3 commented Mar 10, 2021

cannot reproduce… I used same file

Just typing fmt. can not re-produce in this file. You must do as the gif showing

you should try this modified file:

clone the whole repo https://github.com/blevesearch/bleve, and replace the go file analysis/lang/fr/light_stemmer_fr_test.go with this one:

https://gist.githubusercontent.com/ttys3/a0fd236ebff873204927f090f84a33fe/raw/77067a8b477071e929cfa6cc3f911cc2665930ff/light_stemmer_fr_test.go

@ttys3
Copy link
Author

ttys3 commented Mar 10, 2021

@mjlbach confirmed: using the minimal_init.lua (https://github.com/neovim/nvim-lspconfig/blob/master/test/minimal_init.lua) can not re-produce the issue.

@mjlbach
Copy link
Contributor

mjlbach commented Mar 10, 2021

Seems like you should bisect your config then to find the offending plugin :)

@ttys3
Copy link
Author

ttys3 commented Mar 15, 2021

@mjlbach got nvim-treesitter removed and problem still exists. use my own config above and remove nvim-lua/completion-nvim, seems Ok (will not stuck on 100%, first 100% then the CPU usage will go normal)

@mjlbach
Copy link
Contributor

mjlbach commented Mar 15, 2021

So it seems like a completion.nvim issue then? Did you try comp-e?

@ttys3
Copy link
Author

ttys3 commented Mar 15, 2021

@mjlbach nvim-lua/completion-nvim do have performance problem ( CPU goes hight if I press xxxxxxxxxxxxxxx very fast. but it will not cause the CPU stuck on 100% ).

After I add this to my Makefile, finally I found the reason:

	# pure all before debug problems
purge:
	mv ~/.config/nvim/init.vim{,.disabled}
	mv ~/.config/nvim/init.lua{,.disabled}
	rm -rf ~/.local/share/nvim && mkdir ~/.local/share/nvim && rm -rf ~/.cache/nvim && mkdir ~/.cache/nvim && rm -rf rm -rf /tmp/site
	curl -fLo $$HOME/.local/share/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

caused by treesiter related plugin: https://github.com/p00f/nvim-ts-rainbow

disable the plugin, the CPU will not stuck on 100% now. (CPU usage will go down to 0 if we stop press xxxxxxxxxxx crazyly, but it will not if we have treesitter and the nvim-ts-rainbow enabled)

I do disabled all plugins (including nvim-ts-rainbow) by using nvim -u debug_slow.vim but the problem is

init.vim and init.lua must got moved to another name.

and some cache files related to nvim must got removed.

otherwise the test result will resuting wrong

and the result in CPU goes 100% and CPU stuck on 100% is different.

@mjlbach
Copy link
Contributor

mjlbach commented Mar 15, 2021

Alright, I'm going to close the issue here then (since it's an issue with plugins), but I recommend you file issues with nvim-ts-rainbow and completion.nvim, I'm not sure what the status of the latter plugin is.

@ttys3
Copy link
Author

ttys3 commented Mar 15, 2021

@mjlbach OK, to test if completion.nvim has perf problem, I'll try hrsh7th/nvim-compe and compare the result if I have time.

@matu3ba
Copy link

matu3ba commented Mar 15, 2021

@ttys3 Glad you found out about the rainbow problem. Consider only enabling autocomplete on keypress (default is for nvim-compe).

One of the problems is that lua cant drop the amount of data of the lsp in time (we would need sub-ms estimation from the lsp when all data will be there + counters to abort data retrieval + most likely more intelligent caching).

But then still: Is it worth it and feasible to pile up those complexity and should we not simply give advise and tools for proper project setups?
=> Having simple (hardware) counters should be sufficient to have better user estimations how long what data source needs to be retrieved. Sadly lua(jit) does not offer these in sub-ms area.

@mjlbach
Copy link
Contributor

mjlbach commented Mar 15, 2021

This is off-topic, but we do incremental sync now by default (so the amount of data sent is very small), and mfussengers has a PR to do debouncing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issues reporting wrong behavior lsp
Projects
None yet
Development

No branches or pull requests

4 participants