IssueRaiser

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

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: ```ts 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 p

Posted by DanTup on Jun 17, 2019, 10:08 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.3,500 issues0 comments

github (EdTech)

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

DanTupJun 17, 2019, 10:08 AM

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: ```ts 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 p

Comments (0)

No comments yet. Start the discussion.

Comment on this issue