castwide / solargraph

A Ruby language server.
https://solargraph.org
MIT License
1.89k stars 158 forks source link

Indexing is very slow in particular project #682

Open Drowze opened 1 year ago

Drowze commented 1 year ago

(using latest 0.49.0 version with solargraph-rails 1.1.0 on ruby 3.2.2, after running yard gems)

Trying to index the files on a particular project Rails takes too long to finish. The project is big though not particularly huge.

By the way is there a way to disable indexing current project's gems? I wouldn't mind to have only the current project's methods/constants indexed if that's possible and positively impact indexing performance.

Current project vs performance:

$ fd -e rb | wc -l # total number of rb files
    7085

$ cat Gemfile | grep --count -E '^\s*gem ' # amount of gems (explicitly required)
186

$ cat Gemfile.lock | grep --count -E '^\s*[a-zA-Z_-]+ \(\d' # amount of gems (including dependencies)
393

$ time solargraph scan -v
# ... 269144 lines of output, but doesn't seem to indicate any infinite loop
________________________________________________________
Executed in  654.36 secs    fish           external
   usr time  328.32 secs    0.21 millis  328.32 secs
   sys time  117.21 secs    2.45 millis  117.21 secs

When trying to use solargraph with neovim (via nvim-lspconfig, with debug logs enabled and manually edited solargraph's logging.rb to force DEBUG log level):

[START][2023-08-30 09:14:00] LSP logging initiated
[INFO][2023-08-30 09:14:00] .../vim/lsp/rpc.lua:662 "Starting RPC client"   {  args = { "exec", "solargraph", "stdio" },  cmd = "/Users/Drowze/.gem/ruby/3.2.2/bin/bundle",  extra = {    cwd = "REDACTED"  }}
[DEBUG][2023-08-30 09:14:00] .../vim/lsp/rpc.lua:284    "rpc.send"  {  id = 1,  jsonrpc = "2.0",  method = "initialize",  params = {    capabilities = {      textDocument = {        callHierarchy = {          dynamicRegistration = false        },        codeAction = {          codeActionLiteralSupport = {            codeActionKind = {              valueSet = { "", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" }            }          },          dataSupport = true,          dynamicRegistration = false,          isPreferredSupport = true,          resolveSupport = {            properties = { "edit" }          }        },        completion = {          completionItem = {            commitCharactersSupport = true,            deprecatedSupport = true,            documentationFormat = { "markdown", "plaintext" },            insertReplaceSupport = true,            insertTextModeSupport = {              valueSet = { 1, 2 }            },            labelDetailsSupport = true,            preselectSupport = true,            resolveSupport = {              properties = { "documentation", "detail", "additionalTextEdits", "sortText", "filterText", "insertText", "textEdit", "insertTextFormat", "insertTextMode" }            },            snippetSupport = true,            tagSupport = {              valueSet = { 1 }            }          },          completionItemKind = {            valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 }          },          completionList = {            itemDefaults = { "commitCharacters", "editRange", "insertTextFormat", "insertTextMode", "data" }          },          contextSupport = true,          dynamicRegistration = false,          insertTextMode = 1        },        declaration = {          linkSupport = true        },        definition = {          linkSupport = true        },        documentHighlight = {          dynamicRegistration = false        },        documentSymbol = {          dynamicRegistration = false,          hierarchicalDocumentSymbolSupport = true,          symbolKind = {            valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }          }        },        hover = {          contentFormat = { "markdown", "plaintext" },          dynamicRegistration = false        },        implementation = {          linkSupport = true        },        publishDiagnostics = {          relatedInformation = true,          tagSupport = {            valueSet = { 1, 2 }          }        },        references = {          dynamicRegistration = false        },        rename = {          dynamicRegistration = false,          prepareSupport = true        },        semanticTokens = {          augmentsSyntaxTokens = true,          dynamicRegistration = false,          formats = { "relative" },          multilineTokenSupport = false,          overlappingTokenSupport = true,          requests = {            full = {              delta = true            },            range = false          },          serverCancelSupport = false,          tokenModifiers = { "declaration", "definition", "readonly", "static", "deprecated", "abstract", "async", "modification", "documentation", "defaultLibrary" },          tokenTypes = { "namespace", "type", "class", "enum", "interface", "struct", "typeParameter", "parameter", "variable", "property", "enumMember", "event", "function", "method", "macro", "keyword", "modifier", "comment", "string", "number", "regexp", "operator", "decorator" }        },        signatureHelp = {          dynamicRegistration = false,          signatureInformation = {            activeParameterSupport = true,            documentationFormat = { "markdown", "plaintext" },            parameterInformation = {              labelOffsetSupport = true            }          }        },        synchronization = {          didSave = true,          dynamicRegistration = false,          willSave = true,          willSaveWaitUntil = true        },        typeDefinition = {          linkSupport = true        }      },      window = {        showDocument = {          support = true        },        showMessage = {          messageActionItem = {            additionalPropertiesSupport = false          }        },        workDoneProgress = true      },      workspace = {        applyEdit = true,        configuration = true,        didChangeWatchedFiles = {          dynamicRegistration = false,          relativePatternSupport = true        },        semanticTokens = {          refreshSupport = true        },        symbol = {          dynamicRegistration = false,          hierarchicalWorkspaceSymbolSupport = true,          symbolKind = {            valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }          }        },        workspaceEdit = {          resourceOperations = { "rename", "create", "delete" }        },        workspaceFolders = true      }    },    clientInfo = {      name = "Neovim",      version = "0.9.1"    },    initializationOptions = {      formatting = true    },    processId = 29389,    rootPath = "REDACTED",    rootUri = "REDACTED",    trace = "off",    workspaceFolders = { {        name = "REDACTED",        uri = "REDACTED"      } }  }}
[ERROR][2023-08-30 09:14:01] .../vim/lsp/rpc.lua:734    "rpc"   "/Users/Drowze/.gem/ruby/3.2.2/bin/bundle"  "stderr"    "Solargraph is listening on stdio PID=29459\n"
[ERROR][2023-08-30 09:14:01] .../vim/lsp/rpc.lua:734    "rpc"   "/Users/Drowze/.gem/ruby/3.2.2/bin/bundle"  "stderr"    "[INFO] Server received initialize\n"
[ERROR][2023-08-30 09:14:01] .../vim/lsp/rpc.lua:734    "rpc"   "/Users/Drowze/.gem/ruby/3.2.2/bin/bundle"  "stderr"    '[DEBUG] {"params"=>{"rootPath"=>"REDACTED", "rootUri"=>"REDACTED", "workspaceFolders"=>[{"uri"=>"REDACTED", "name"=>"REDACTED"}], "initializationOptions"=>{"formatting"=>true}, "processId"=>29389, "clientInfo"=>{"name"=>"Neovim", "version"=>"0.9.1"}, "trace"=>"off", "capabilities"=>{"window"=>{"workDoneProgress"=>true, "showMessage"=>{"messageActionItem"=>{"additionalPropertiesSupport"=>false}}, "showDocument"=>{"support"=>true}}, "workspace"=>{"didChangeWatchedFiles"=>{"relativePatternSupport"=>true, "dynamicRegistration"=>false}, "workspaceFolders"=>true, "applyEdit"=>true, "semanticTokens"=>{"refreshSupport"=>true}, "symbol"=>{"dynamicRegistration"=>false, "hierarchicalWorkspaceSymbolSupport"=>true, "symbolKind"=>{"valueSet"=>[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}}, "workspaceEdit"=>{"resourceOperations"=>["rename", "create", "delete"]}, "configuration"=>true}, "textDocument"=>{"hover"=>{"contentFormat"=>["markdown", "plaintext"], "dynamicRegistration"=>false}, "documentHighlight"=>{"dynamicRegistration"=>false}, "documentSymbol"=>{"hierarchicalDocumentSymbolSupport"=>true, "dynamicRegistration"=>false, "symbolKind"=>{"valueSet"=>[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}}, "implementation"=>{"linkSupport"=>true}, "typeDefinition"=>{"linkSupport"=>true}, "synchronization"=>{"dynamicRegistration"=>false, "willSave"=>true, "didSave"=>true, "willSaveWaitUntil"=>true}, "publishDiagnostics"=>{"tagSupport"=>{"valueSet"=>[1, 2]}, "relatedInformation"=>true}, "codeAction"=>{"codeActionLiteralSupport"=>{"codeActionKind"=>{"valueSet"=>["", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports"]}}, "isPreferredSupport"=>true, "dataSupport"=>true, "dynamicRegistration"=>false, "resolveSupport"=>{"properties"=>["edit"]}}, "definition"=>{"linkSupport"=>true}, "callHierarchy"=>{"dynamicRegistration"=>false}, "rename"=>{"prepareSupport"=>true, "dynamicRegistration"=>false}, "declaration"=>{"linkSupport"=>true}, "semanticTokens"=>{"overlappingTokenSupport"=>true, "multilineTokenSupport"=>false, "serverCancelSupport"=>false, "augmentsSyntaxTokens"=>true, "tokenModifiers"=>["declaration", "definition", "readonly", "static", "deprecated", "abstract", "async", "modification", "documentation", "defaultLibrary"], "requests"=>{"full"=>{"delta"=>true}, "range"=>false}, "dynamicRegistration"=>false, "tokenTypes"=>["namespace", "type", "class", "enum", "interface", "struct", "typeParameter", "parameter", "variable", "property", "enumMember", "event", "function", "method", "macro", "keyword", "modifier", "comment", "string", "number", "regexp", "operator", "decorator"], "formats"=>["relative"]}, "signatureHelp"=>{"signatureInformation"=>{"documentationFormat"=>["markdown", "plaintext"], "activeParameterSupport"=>true, "parameterInformation"=>{"labelOffsetSupport"=>true}}, "dynamicRegistration"=>false}, "completion"=>{"dynamicRegistration"=>false, "insertTextMode"=>1, "completionList"=>{"itemDefaults"=>["commitCharacters", "editRange", "insertTextFormat", "insertTextMode", "data"]}, "completionItemKind"=>{"valueSet"=>[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]}, "contextSupport"=>true, "completionItem"=>{"snippetSupport"=>true, "commitCharactersSupport"=>true, "preselectSupport"=>true, "deprecatedSupport"=>true, "documentationFormat"=>["markdown", "plaintext"], "tagSupport"=>{"valueSet"=>[1]}, "insertReplaceSupport"=>true, "insertTextModeSupport"=>{"valueSet"=>[1, 2]}, "labelDetailsSupport"=>true, "resolveSupport"=>{"properties"=>["documentation", "detail", "additionalTextEdits", "sortText", "filterText", "insertText", "textEdit", "insertTextFormat", "insertTextMode"]}}}, "references"=>{"dynamicRegistration"=>false}}}}, "method"=>"initialize", "id"=>1, "jsonrpc"=>"2.0"}\n'
[DEBUG][2023-08-30 09:18:20] .../vim/lsp/rpc.lua:387    "rpc.receive"   {  id = 1,  jsonrpc = "2.0",  result = {    capabilities = {      completionProvider = {        resolveProvider = true,        triggerCharacters = { ".", ":", "@" }      },      definitionProvider = true,      documentFormattingProvider = true,      documentHighlightProvider = true,      documentSymbolProvider = true,      foldingRangeProvider = true,      hoverProvider = true,      referencesProvider = true,      renameProvider = {        prepareProvider = true      },      signatureHelpProvider = {        triggerCharacters = { "(", "," }      },      textDocumentSync = 2,      workspace = {        workspaceFolders = {          changeNotifications = true,          supported = true        }      },      workspaceSymbolProvider = true    }  }}
[DEBUG][2023-08-30 09:18:20] .../vim/lsp/rpc.lua:284    "rpc.send"  {  jsonrpc = "2.0",  method = "initialized",  params = vim.empty_dict()}
[DEBUG][2023-08-30 09:18:20] .../vim/lsp/rpc.lua:284    "rpc.send"  {  jsonrpc = "2.0",  method = "workspace/didChangeConfiguration",  params = {    settings = {      solargraph = {        diagnostics = true      }    }  }}
[DEBUG][2023-08-30 09:18:20] .../vim/lsp/rpc.lua:284    "rpc.send"  {  jsonrpc = "2.0",  method = "workspace/didChangeConfiguration",  params = {    settings = {      solargraph = {        diagnostics = true      }    }  }}
[INFO][2023-08-30 09:18:20] .../lua/vim/lsp.lua:1345    "LSP[solargraph]"   "server_capabilities"   {  server_capabilities = {    completionProvider = {      resolveProvider = true,      triggerCharacters = { ".", ":", "@" }    },    definitionProvider = true,    documentFormattingProvider = true,    documentHighlightProvider = true,    documentSymbolProvider = true,    foldingRangeProvider = true,    hoverProvider = true,    referencesProvider = true,    renameProvider = {      prepareProvider = true    },    signatureHelpProvider = {      triggerCharacters = { "(", "," }    },    textDocumentSync = {      change = 2,      openClose = true,      save = {        includeText = false      },      willSave = false,      willSaveWaitUntil = false    },    workspace = {      workspaceFolders = {        changeNotifications = true,        supported = true      }    },    workspaceSymbolProvider = true  }}
[DEBUG][2023-08-30 09:18:20] .../vim/lsp/rpc.lua:284    "rpc.send"  {  jsonrpc = "2.0",  method = "textDocument/didOpen",  params = {    textDocument = {      languageId = "ruby",      text = 'REDACTED',      uri = "REDACTED",      version = 0    }  }}
[DEBUG][2023-08-30 09:18:20] .../vim/lsp/rpc.lua:387    "rpc.receive"   {  id = 1,  jsonrpc = "2.0",  method = "window/workDoneProgress/create",  params = {    token = "241c740a-0e28-41ff-bbf2-4aca84b4f7f1"  }}
[DEBUG][2023-08-30 09:18:20] .../vim/lsp/rpc.lua:403    "server_request: callback result"   {  result = vim.NIL,  status = true}
[DEBUG][2023-08-30 09:18:20] .../vim/lsp/rpc.lua:284    "rpc.send"  {  id = 1,  jsonrpc = "2.0",  result = vim.NIL}
[DEBUG][2023-08-30 09:18:21] .../vim/lsp/rpc.lua:387    "rpc.receive"   {  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "241c740a-0e28-41ff-bbf2-4aca84b4f7f1",    value = {      cancellable = false,      kind = "begin",      message = "0/5349 files",      percentage = 0,      title = "Mapping workspace"    }  }}
[DEBUG][2023-08-30 09:18:22] .../vim/lsp/rpc.lua:387    "rpc.receive"   {  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "241c740a-0e28-41ff-bbf2-4aca84b4f7f1",    value = {      cancellable = false,      kind = "report",      message = "535/5349 files",      percentage = 10    }  }}
[DEBUG][2023-08-30 09:18:23] .../vim/lsp/rpc.lua:387    "rpc.receive"   {  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "241c740a-0e28-41ff-bbf2-4aca84b4f7f1",    value = {      cancellable = false,      kind = "report",      message = "1070/5349 files",      percentage = 20    }  }}
[DEBUG][2023-08-30 09:18:24] .../vim/lsp/rpc.lua:387    "rpc.receive"   {  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "241c740a-0e28-41ff-bbf2-4aca84b4f7f1",    value = {      cancellable = false,      kind = "report",      message = "1605/5349 files",      percentage = 30    }  }}
[DEBUG][2023-08-30 09:18:26] .../vim/lsp/rpc.lua:387    "rpc.receive"   {  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "241c740a-0e28-41ff-bbf2-4aca84b4f7f1",    value = {      cancellable = false,      kind = "report",      message = "2140/5349 files",      percentage = 40    }  }}
[DEBUG][2023-08-30 09:18:27] .../vim/lsp/rpc.lua:387    "rpc.receive"   {  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "241c740a-0e28-41ff-bbf2-4aca84b4f7f1",    value = {      cancellable = false,      kind = "report",      message = "2675/5349 files",      percentage = 50    }  }}
[DEBUG][2023-08-30 09:18:30] .../vim/lsp/rpc.lua:387    "rpc.receive"   {  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "241c740a-0e28-41ff-bbf2-4aca84b4f7f1",    value = {      cancellable = false,      kind = "report",      message = "3210/5349 files",      percentage = 60    }  }}
[DEBUG][2023-08-30 09:18:39] .../vim/lsp/rpc.lua:387    "rpc.receive"   {  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "241c740a-0e28-41ff-bbf2-4aca84b4f7f1",    value = {      cancellable = false,      kind = "report",      message = "3745/5349 files",      percentage = 70    }  }}
[DEBUG][2023-08-30 09:18:41] .../vim/lsp/rpc.lua:387    "rpc.receive"   {  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "241c740a-0e28-41ff-bbf2-4aca84b4f7f1",    value = {      cancellable = false,      kind = "report",      message = "4280/5349 files",      percentage = 80    }  }}
[DEBUG][2023-08-30 09:18:44] .../vim/lsp/rpc.lua:387    "rpc.receive"   {  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "241c740a-0e28-41ff-bbf2-4aca84b4f7f1",    value = {      cancellable = false,      kind = "report",      message = "4815/5349 files",      percentage = 90    }  }}
[DEBUG][2023-08-30 09:18:47] .../vim/lsp/rpc.lua:387    "rpc.receive"   {  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "241c740a-0e28-41ff-bbf2-4aca84b4f7f1",    value = {      cancellable = false,      kind = "report",      message = "5349/5349 files",      percentage = 100    }  }}
[DEBUG][2023-08-30 09:18:47] .../vim/lsp/rpc.lua:387    "rpc.receive"   {  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "241c740a-0e28-41ff-bbf2-4aca84b4f7f1",    value = {      kind = "end",      message = "Mapping complete"    }  }}
[DEBUG][2023-08-30 09:19:05] .../vim/lsp/rpc.lua:387    "rpc.receive"   {  jsonrpc = "2.0",  method = "textDocument/publishDiagnostics",  params = {    diagnostics = { {        code = "Layout/LineLength",        message = " Line is too long. [122/120]",        range = {          ["end"] = {            character = 122,            line = 169          },          start = {            character = 120,            line = 169          }        },        severity = 3,        source = "rubocop"      } },    uri = "REDACTED"  }}

config:

---
include:
- "**/*.rb"
exclude:
- spec/**/*
- test/**/*
- vendor/**/*
- public/**/*
plugins:
- solargraph-rails
max_files: 10000

I'm not sure how to debug further but would be happy to help as I can. Solargraph is an important piece at my (and my colleagues') workflows.