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

Significant Performance Degradation on Large File #8115

Open
pingshunhuangalex opened this issue Nov 23, 2022 · 7 comments
Open

Significant Performance Degradation on Large File #8115

pingshunhuangalex opened this issue Nov 23, 2022 · 7 comments

Comments

@pingshunhuangalex
Copy link

Describe the bug
I have a couple of 120k lines YAML files which I edit on a daily basis. With recent updates (in the past month or even a couple of weeks ago), VS Code has become so laggy that the letter needs to catch up when I type, and moving lines up and down becomes a nightmare. Keystrokes also get swallowed from time to time which makes things unusable.

Turning the extension off seems to fix the issue, but I really don't want to. Also please note that this was never a problem with VS Code Vim until recently. I can reproduce it on both Windows and Mac machines. Tried fresh reinstallation, but it doesn't do anything.

To Reproduce
Steps to reproduce the behavior:

  1. Open a large file with let's say 120k
  2. Type quickly or try any basic line movement

Expected behavior
There shouldn't be any lag for basic operations and typing

Screenshots
With VS Code Vim ON

Nov-24-2022 10-46-34

With VS Code Vim OFF

Nov-24-2022 10-42-58

Environment (please complete the following information):

Version: 1.74.0-insider
Date: 2022-11-23T05:28:16.879Z
Electron: 19.1.3
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Darwin arm64 21.6.0
Sandboxed: Yes
VS Code Vim Version: v1.24.3
@Arcitec
Copy link

Arcitec commented Jan 31, 2023

@pingshunhuangalex Interesting problem.

Have you tried this instead?

https://marketplace.visualstudio.com/items?itemName=asvetliakov.vscode-neovim

According to this article, it's much, much faster:

https://galenwong.github.io/blog/2021-03-22-vscode-neovim-vs-vscodevim/

And it uses native NeoVim, so there's no need to emulate Vim in JavaScript. It's all running natively with full support for all Vim commands.

Edit: The reason for VSCodeVim's slowness is because of how VSCode implements the JavaScript extension host. It's explained by a team member of VSCodeVim, who even recommended NeoVim as a solution:

#7546 (comment)

Someone even replied in that thread and said:

"I've just changed to vscode-neovim. Crazy fast."

Edit again: Here's someone who explains why the NeoVim extension is so much faster:

#7415 (comment)

In short, it seems to be because VSCodeVim has to register a type event handler in VSCode, which is a very slow action due to a problem in VSCode. Seems related to calling the default type handler from within a custom type handler. It also seems like something related to autocompletion is slowing things down further.

The NeoVim plugin doesn't do that. It unregisters the type handler while you write code, and sends all input to the NeoVim process instead. Then when you hit Escape to "return to VSCode" it re-registers the normal type handler. So there's no lag/delay at all, because VSCode's keyboard handler is "disabled" while you are writing code in NeoVim.

@pingshunhuangalex
Copy link
Author

Thanks for the suggestion @Bananaman

I've hesitated before between the 2 options and picked VSCodeVim back then, probably cuz it's maintained by Microsoft devs.

I've accumulated quite a bit of configs and became reluctant to migrate. Maybe it's time to change now. Thanks.

@Arcitec
Copy link

Arcitec commented Jan 31, 2023

@pingshunhuangalex Yeah I know the problem about having a lot of configs, but I think it's better to have a usable editor than a super laggy one. Slow text is so bad for productivity and peace of mind. :/

I heard so many good reviews for NeoVim plugin and will switch to it.

VSCodeVim isn't maintained by Microsoft by the way? At least if I look at the contributors, I can't find any Microsoft devs:

https://github.com/VSCodeVim/Vim/graphs/contributors

It's mainly maintained by https://github.com/J-Fields who works at another company.

@Arcitec
Copy link

Arcitec commented Jan 31, 2023

@pingshunhuangalex Oh, I was thinking about this again and just realized that there may have been a misunderstanding.

I wasn't saying "switch to NeoVim". :D

  • VSCode: Owned and maintained by microsoft.
  • VSCodeVim: This plugin, tries to emulate Vim in JavaScript but is slow because of VSCode issues. It is not maintained by Microsoft.
  • NeoVim: A different editor that uses different configs. I don't want to switch to it, because it's hard to set up and uses 100% keyboard controls, no GUI. I have used Vim in terminals in the past as my main editor and it's good but it's so much work to set up and maintain it. So I am not gonna go back to it.
  • NeoVim Plugin for VSCode: It's a plugin that makes VSCode use a NeoVim "process" for text input which means 100% perfect Vim compatibility inside VSCode. It even supports Vim plugins, so we can add stuff like "di{" for "delete inside brackets" plugin and EasyMotion plugin etc. It uses VSCode for "insert mode" (text typing/autocompletion), and uses NeoVim for movements and editing movements (like jump/move, delete, copy, paste) every time you press Escape to leave "insert mode". So it's the best of both worlds. It even supports advanced Vim actions like visual mode's block copy and block paste.

The last one is what I said we should switch to:

https://marketplace.visualstudio.com/items?itemName=asvetliakov.vscode-neovim

@MurtadhaInit
Copy link

Thank you for the suggestion @Bananaman I didn't know such an extension existed. I'll give it a try. I came across this issue as the first thing I've noticed immediately after installing this plugin is the bizarre inconsistency even when navigating in normal mode.

Sometimes hitting the h key moves left, and sometimes it just decides not to do anything! Same thing when holding it: it either moves normally as expected, or just takes a moment then moves.

It's a shame. I really hope Microsoft works on a native Vim plugin, even if with a basic functionality. I think the Vim plugin in JetBrains IDEs is developed by JetBrains.

@jvanheugten
Copy link

I have the same issue but in a 6000 line Markdown file. Typing gets really slow with the VIM extension enabled (I had found this through the VSCode Bisection of plugins).

@LuSrackhall
Copy link

LuSrackhall commented Feb 4, 2025

@pingshunhuangalex Oh, I was thinking about this again and just realized that there may have been a misunderstanding.

I wasn't saying "switch to NeoVim". :D

  • VSCode: Owned and maintained by microsoft.
  • VSCodeVim: This plugin, tries to emulate Vim in JavaScript but is slow because of VSCode issues. It is not maintained by Microsoft.
  • NeoVim: A different editor that uses different configs. I don't want to switch to it, because it's hard to set up and uses 100% keyboard controls, no GUI. I have used Vim in terminals in the past as my main editor and it's good but it's so much work to set up and maintain it. So I am not gonna go back to it.
  • NeoVim Plugin for VSCode: It's a plugin that makes VSCode use a NeoVim "process" for text input which means 100% perfect Vim compatibility inside VSCode. It even supports Vim plugins, so we can add stuff like "" for "delete inside brackets" plugin and EasyMotion plugin etc. It uses VSCode for "insert mode" (text typing/autocompletion), and uses NeoVim for movements and editing movements (like jump/move, delete, copy, paste) every time you press Escape to leave "insert mode". So it's the best of both worlds. It even supports advanced Vim actions like visual mode's block copy and block paste.di{

The last one is what I said we should switch to:

https://marketplace.visualstudio.com/items?itemName=asvetliakov.vscode-neovim

I noticed that in the settings of VSCodeVim, it seems to support using Neovim as a backend and can also use some .vimrc configurations.I wonder if this can eventually solve the problem (it doesn't seem to work at the moment).

https://github.com/VSCodeVim/Vim?tab=readme-ov-file#neovim-integration:~:text=200-,Neovim%20Integration,Faster%20search%20and%20replace!,-Key%20Remapping

#1735
#1725
#1724

Image

Finally, I think you are right. (Although I am somewhat reluctant to give up my current plugin configuration, the ecosystem on Neovim seems more active, and I should be able to configure it quickly. Thank you for your recommendation.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants