question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extensions using the "type" command (for ex. Vim) have poor performance due to being single-threaded with other extensions

See original GitHub issue

I don’t know if this is a known/accepted issue, but I’ve had a number of users complain of poor performance in the editor when using my extension along with the Vim extension.

This appears to be because the Vim extension uses the type command to handle keypresses (in the extension host). This means if pressing a key triggers a command that blocks in another extension (for example the first character press can trigger code completion, which if the list is 20,000 items can block the thread for a little while while they’re build + serialised) the typing in the editor is really sluggish.

You can easily reproduce this by making an extension that blocks for 1s when asked for completions:

context.subscriptions.push(vscode.languages.registerCompletionItemProvider({ scheme: "file" }, {
	provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, context: vscode.CompletionContext): vscode.ProviderResult<vscode.CompletionItem[] | vscode.CompletionList> {
		console.log('Completion request');
		var start = Date.now();
		let i = 0;
		while (Date.now() < start + 10000) {
			// Block for a second...
			i++;
		}
		return [new vscode.CompletionItem(`aaaItem (${i} iterations)`)];
	},
}));

If you run this and enabled the Vim plugin, when you start typing on a newline (which triggers completion), the characters you type won’t appear for a while.

Of course, extensions should try to avoid blocking the extension host as much as possible, but sometimes it’s unavoidable (for ex. assembling and serialising a huge number of completion items). It’s not clear where users should raise bugs, since in isolation neither extension is really doing anything wrong.

I don’t know what the fix is (separate extension host for type-handling extensions might work, but that might also be a huge task), but I couldn’t find any issues discussing this and figured it was worth some discussion (even if only to have the information described in one place we can point people to that hit these issue).

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:232
  • Comments:47 (31 by maintainers)

github_iconTop GitHub Comments

55reactions
alexdimacommented, Mar 25, 2022

In our latest Insiders Build, we have added a new experimental setting that would allow to execute the vim extension in a dedicated extension host process.

Configure the following in your settings.json and then reload window or restart:

"extensions.experimental.affinity": {
	"vscodevim.vim": 1,
	"asvetliakov.vscode-neovim": 1
},

You can double check that vim is loaded in a separate process using F1 > Developer: Show Running Extensions:

image
20reactions
xconvergecommented, Aug 24, 2019

I am pretty bummed that we have brought the Vim extension to where it is now, and are constantly bombarded with performance issue reports. It is almost “good enough” but this caveat is enough to turn a percentage of users away from the experience and it is a bit demoralizing at times to have no path forward.

Thanks for the explanations in this issue report though, the comments have cleared up a few things for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

they probably just don't do anything that keeps the extension ...
Extensions using the "type" command (for ex. Vim) have poor performance due to being single-threa... I don't know if this is a known/accepted...
Read more >
Vim - Visual Studio Marketplace
Launch VS Code Quick Open ( Ctrl+P ), paste the following command, and press enter. Copy. Copied to clipboard. More Info ...
Read more >
awesome-vscode | A curated list of delightful VS Code ...
Using VS Code with particular technologies; Lint and IntelliSense ... Vim Mode - Relatively new, but promising extension implementing Vim features in VSCode ......
Read more >
Managing file systems Red Hat Enterprise Linux 8
Example Ansible playbook to resize an existing file system on LVM using the storage RHEL ... XFS has a relatively low performance for...
Read more >
CodeMirror 5 User Manual
The easiest way to use CodeMirror is to simply load the script and style sheet found under lib/ in the distribution, plus a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found