bartosz-antosik / vscode-spellright

Multilingual, Offline and Lightweight Spellchecker for Visual Studio Code
Other
360 stars 37 forks source link

Extension causes huge typing latency spikes #321

Open Valloric opened 5 years ago

Valloric commented 5 years ago

Repro steps:

  1. My entire vscode config is here. vscode_setup.sh can install all the extensions I use.
  2. VS Code version info included below.
  3. Open this file.
  4. Make sure spellright is enabled and the en_US dictionary (default from Debian) is loaded.
  5. Start typing gibberish inside the license header (comment) at the top of the file. Gibberish is important to trigger spelling mistakes for every word.
  6. Observe huge typing latency before even hitting the 80th column.

I can observe CPU usage climbs to +90% as well during step 5 above. This is on a workstation machine using a beefy Intel Core i5-8600K CPU @ 3.60GHz.

Disabling only this extension removes all typing latency. Typing gibberish outside of a comment region (where spell checking is disabled) shows latency spikes during typing.

If it's hard to nail down what's causing this (and even if it's not), I'd appreciate an option that delays spell checking until the user has stopped typing for 100ms (or more). This would prevent the extension from interfering with character input. I don't need spell check to run after every character typed and I doubt anyone else needs it either.

VS Code version info: Version: 1.40.0 Commit: 86405ea23e3937316009fc27c9361deee66ffbf5 Date: 2019-11-06T18:14:08.920Z Electron: 6.1.2 Chrome: 76.0.3809.146 Node.js: 12.4.0 V8: 7.6.303.31-electron.0 OS: Linux x64 4.19.0-5-amd64

Valloric commented 5 years ago

Interestingly, disabling every extension except this one does not lead to the input latency spike on gibberish but it does still lead to 100% CPU usage. My guess is that while this extension is doing something suboptimal, things get even worse when it interacts with one of my other extensions.

I used the command below.

code --disable-extension bbenoist.togglehs \
--disable-extension  DavidAnson.vscode-markdownlint \
--disable-extension  foxundermoon.shell-format \
 --disable-extension Gruntfuggly.todo-tree \
 --disable-extension  llvm-vs-code-extensions.vscode-clangd \
  --disable-extension mrcrowl.hg \
  --disable-extension ms-python.python \
  --disable-extension richie5um2.vscode-sort-json \
  --disable-extension rust-lang.rust \
  --disable-extension vscode-icons-team.vscode-icons \
  --disable-extension vscodevim.vim .
Valloric commented 5 years ago

My intuition was correct: this extension pairs badly with the Vim emulation extension. Note that VS Code Vim is an incredibly popular extension.

I ran the same experiment with this command:

code --disable-extension bbenoist.togglehs \
--disable-extension  DavidAnson.vscode-markdownlint \
--disable-extension  foxundermoon.shell-format \
 --disable-extension Gruntfuggly.todo-tree \
 --disable-extension  llvm-vs-code-extensions.vscode-clangd \
  --disable-extension mrcrowl.hg \
  --disable-extension ms-python.python \
  --disable-extension richie5um2.vscode-sort-json \
  --disable-extension rust-lang.rust \
  --disable-extension vscode-icons-team.vscode-icons \

That disables everything except VS Code Vim and spellright. I could repro the input latency spike.

bartosz-antosik commented 5 years ago

Thank you for thorough investigation. This issue is somehow known to me (#1) and it has been mitigated a bit since then but still the only way to fight it properly is, I presume, delegate the extension to Language Server. It has been partially done alas, I have very little time recently to deal with the extension.

ogmios-voice commented 4 years ago

huge typing latency before even hitting the 80th column

All of this means that the spell checking itself is very slow. I'm also affected by this problem, and based on the very high CPU usage, it seems to me more like a brute force search instead of a (fast) map based solution (I haven't checked the code, so I don't know for sure). What algorithm is the spell checking based on?

majkinetor commented 2 weeks ago

Yeah, its very slow.

I have one file in which copy/paste lasts 10s each time. I have never seen this behavior in vscode on any other place, its disturbing - there is a loader after you CTRL+V! I had to exclude this file in settings. Its not a big file, just a 500 lines of links like this:

links.md ![image](https://github.com/user-attachments/assets/22bfae0c-2680-4e1c-bc25-5afe3f502cc8)