Skip to content

Improve performance of completions #1750

@DanTup

Description

@DanTup

As well as probably being the cause of #1721, the performance of completions with unimported symbols is generally poor.

Testing on Windows PC with the following test (inside test\flutter_only\providers\completion_item_provider.test.ts):

	describe("with SuggestionSet support", () => {
		beforeEach("ensure SuggestionSets are supported", function () {
			if (!extApi.analyzerCapabilities.supportsAvailableSuggestions)
				this.skip();
		});

		it.only("includes unimported symbols", async () => {
			await setTestContent(`
main() {
  ProcessInf
}
		`);
			const count = 50;
			const start = Date.now();
			for (let i = 0; i < 50; i++) {
				const completions = await getCompletionsAt("ProcessInf^");
				ensureCompletion(completions, vs.CompletionItemKind.Class, "ProcessInfo", "ProcessInfo");
			}
			const end = Date.now();
			console.log(`Took ${end - start}ms to do ${count} completion requests`);
		});
	});

Output from a few runs:

Took 56426ms to do 50 completion requests
Took 57034ms to do 50 completion requests
Took 57607ms to do 50 completion requests

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions