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

Linter perf improvement - cache LinterAnalyzer in BicepCompilationManager #5578

Merged

Conversation

bhsubra
Copy link
Contributor

@bhsubra bhsubra commented Jan 4, 2022

With current implementation, we create a new LinterAnalyzer on every text edit.

With changes in this PR, we will create a LinterAnalyzer on file open, cache it in BicepCompilationManager and reuse it. A new version of the LinterAnalyzer will be created whenever bicepconfig.json file is modified.

@majastrz
Copy link
Member

majastrz commented Jan 5, 2022

Do you happen to have any data on the impact of the change?

@bhsubra
Copy link
Contributor Author

bhsubra commented Jan 5, 2022

Do you happen to have any data on the impact of the change?

@majastrz, this -

this.configuration = configuration;
gets executed on every edit, which I think is wasteful. We have the ability to detect when there are changes in bicepconfig.json and we can use that to create a new version of LinterAnalyzer. I can measure how much time it takes to create the analyzer, but my guess is it's small. The overall impact depends on number of edits in the file.

To answer your question, I don't have data in terms of perf test(I think this - #1641 needs to happen first). Let me know if we want to do some manual measurements.

Edit:
I did some StopWatch measurements. These are the numbers.
On file open:
image

On edit(any key press event):
image

@bhsubra bhsubra force-pushed the dev/bhsubra/CacheLinterAnalyzerInBicepCompilationManager branch from f11bee1 to 543bad6 Compare January 6, 2022 00:08
@majastrz
Copy link
Member

majastrz commented Jan 7, 2022

I did some StopWatch measurements. These are the numbers. On file open: image

On edit(any key press event): image

Nice!

// We'll use default bicepconfig.json settings during SnippetsProvider creation to avoid errors during language service initialization.
// We don't do any validation in SnippetsProvider. So using default settings shouldn't be a problem.
Compilation compilation = new Compilation(namespaceProvider, sourceFileGrouping, configurationManager.GetBuiltInConfiguration(disableAnalyzers: true));
Compilation compilation = new Compilation(namespaceProvider, sourceFileGrouping, configuration, linterAnalyzer);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linterAnalyzer

Do we need to run the linter rules on the snippets at all?

Copy link
Contributor Author

@bhsubra bhsubra Jan 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@majastrz , no, we don't run linter rules. It uses the configuration with disabled analyzers:

configuration = configurationManager.GetBuiltInConfiguration(disableAnalyzers: true);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will go ahead and merge this PR. I hope I answered your question. If there is any pending action item, I can take care of it in a follow up PR.

@bhsubra bhsubra merged commit 3f01e76 into main Jan 10, 2022
@bhsubra bhsubra deleted the dev/bhsubra/CacheLinterAnalyzerInBicepCompilationManager branch January 10, 2022 16:00
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

Successfully merging this pull request may close these issues.

Set up a way to do some (manual?) perf/stress tests on the linter rules
2 participants