ruby-lsp: Ruby LSP Indexing is very slow on version 0.19.0
Description
Ruby LSP Information
VS Code Version
1.91.1
Ruby LSP Extension Version
0.8.2
Ruby LSP Server Version
0.19.0
Ruby LSP Addons
- Ruby LSP Rails
Ruby Version
3.3.5
Ruby Version Manager
asdf
Installed Extensions
Click to expand
- better-comments (3.0.2)
- cucumberautocomplete (3.0.5)
- vscode-erb-beautify (0.5.0)
- pyright (1.1.327)
- vscode-zipfs (3.0.0)
- vscode-markdownlint (0.56.0)
- vscode-eslint (3.0.10)
- dotenv-vscode (0.28.1)
- gitlens (15.5.1)
- prettier-vscode (11.0.0)
- vscode-pull-request-github (0.92.0)
- todo-tree (0.0.226)
- vscode-drawio (1.6.6)
- prettier-sql-vscode (1.6.0)
- haml (1.4.1)
- mongodb-vscode (1.7.0)
- vscode-docker (1.29.2)
- debugpy (2024.6.0)
- python (2024.12.3)
- vscode-pylance (2024.8.1)
- cpptools (1.21.6)
- cpptools-extension-pack (1.3.0)
- cpptools-themes (2.0.0)
- vscode-versionlens (1.14.2)
- material-icon-theme (5.11.1)
- platformio-ide (3.3.3)
- vscode-xml (0.27.1)
- vscode-yaml (1.15.0)
- trailing-spaces (0.4.1)
- ruby-lsp (0.8.2)
- code-spell-checker (4.0.13)
- code-spell-checker-portuguese-brazilian (2.2.1)
- vscode-stylelint (1.4.0)
- highlight-matching-tag (0.11.0)
- markdown-all-in-one (3.6.2)
Ruby LSP Settings
Click to expand
Workspace
{}
User
{
"enableExperimentalFeatures": false,
"enabledFeatures": {
"codeActions": true,
"diagnostics": true,
"documentHighlights": true,
"documentLink": true,
"documentSymbols": true,
"foldingRanges": true,
"formatting": true,
"hover": true,
"inlayHint": true,
"onTypeFormatting": true,
"selectionRanges": true,
"semanticHighlighting": true,
"completion": true,
"codeLens": true,
"definition": true,
"workspaceSymbol": true,
"signatureHelp": true,
"typeHierarchy": true
},
"featuresConfiguration": {},
"addonSettings": {},
"rubyVersionManager": {
"identifier": "asdf"
},
"customRubyCommand": "",
"formatter": "auto",
"linters": null,
"bundleGemfile": "",
"testTimeout": 30,
"branch": "",
"pullDiagnosticsOn": "both",
"useBundlerCompose": false,
"bypassTypechecker": false,
"rubyExecutablePath": "",
"indexing": {},
"erbSupport": true
}
Reproduction steps
- Open VS Code
- Ruby LSP starts indexing
- On this new version (0.19.0) Indexing is a whole lot slower! 😢 It starts to slow down at 30% on my case.
Code snippet or error message
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 6
- Comments: 16 (9 by maintainers)
Just an update: we’re looking into how we can compute code unit lengths in a more performant way. I’d really like to avoid reverting the multibyte support since it allows developers who write comments in other languages (like Japanese) to have a correct experience using the Ruby LSP.
If we can’t fix it in a timely manner, we will revert and re-evaluate.
Not happening anymore with
0.20.0🎉There’s definitly some time being spend one something. I added some logging and here are my worst offenders:
Most are done very quickly but there’s definitly at least one outlier, taking 38 (!) seconds. With 0.18.4:
It’s still in the Top10 but nowhere near as bad. Overall things seem to be taking longer. I guess
prism/node.rbcontains some special characters but the file is so large and I didn’t find any from scrolling through.Edit: I missed this initially, the file taking so long is the one from prism shipped with ruby by default. The one from the gem (I have it it my dependencies) finishes very quickly in both cases. It used to contain a bunch of non-ascii characters for pretty-printing the ast, which is now part of a different file. https://github.com/ruby/prism/commit/0f21f5bfe1e4a1753c5ddb88b73ffaa6ea641a0c
If I read the code right, it will
dupthe source code from the beginning all the way to the token it is currently looking at which is just horrible for performance the larger the file is.@andyw8
I used the following Regular Expression
[^\x00-\x7f]to search the code base, and found 64 results in 9 Ruby files.Times: