Extensions using the "type" command (for ex. Vim) have poor performance due to being single-threaded with other extensions
See original GitHub issueI 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:
- Created 4 years ago
- Reactions:232
- Comments:47 (31 by maintainers)
Top GitHub Comments
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:You can double check that vim is loaded in a separate process using
F1 > Developer: Show Running Extensions
: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.