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

Improve performance for SymbolReferenceAnalyzer #5548

Merged
merged 9 commits into from
Apr 12, 2022

Conversation

costin-zaharia-sonarsource
Copy link
Member

@costin-zaharia-sonarsource costin-zaharia-sonarsource commented Apr 6, 2022

Rewrite the analyzer to work as much as possible at the syntax level by retrieving symbols only when strictly necessary.

Tested this rule on:

  • akka.net - before: 0:02:49, after: 0:01:32, improvement: 45.94%
  • efcore - before: 0:01:39, after: 0:01:04, improvement: 35.19%
  • nodatime - before: 0:00:06, after: 0:00:04, improvement: 26.02%

Part of #4220

[DataTestMethod]
[DataRow(true)]
[DataRow(false)]
public void GetSetKeyword_ReturnsNull_VB(bool isTestProject) =>
Copy link
Member Author

Choose a reason for hiding this comment

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

"set" keyword was supported only for adding support for "value". This complicated the logic and it was not consistent. The "set" declaration was added only in the presence of "value".

I prefer to remove this part of the functionality and keep the logic simple.

@@ -101,7 +101,7 @@ public class SymbolReferenceAnalyzerTest
[DataRow(ProjectType.Product)]
[DataRow(ProjectType.Test)]
public void Verify_NamedType_CS(ProjectType projectType) =>
Verify("NamedType.cs", projectType, 4, 3, 7, 7); // 'var' and type name on the same line
Copy link
Member Author

Choose a reason for hiding this comment

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

"var" here was redirecting to the underlying type, which was nice. I've dropped the support, for now, to keep the logic simple but I might change my mind until if finish with this rework.

@costin-zaharia-sonarsource costin-zaharia-sonarsource force-pushed the costin/SymbolReference-perf-opt branch 7 times, most recently from 30179bf to f2b464a Compare April 7, 2022 08:23
@costin-zaharia-sonarsource costin-zaharia-sonarsource changed the base branch from master to costin/sra-vb-tests April 7, 2022 08:34
@costin-zaharia-sonarsource costin-zaharia-sonarsource force-pushed the costin/SymbolReference-perf-opt branch 4 times, most recently from 1d93ac6 to 0578574 Compare April 7, 2022 15:14
Base automatically changed from costin/sra-vb-tests to master April 8, 2022 11:15
@costin-zaharia-sonarsource costin-zaharia-sonarsource force-pushed the costin/SymbolReference-perf-opt branch from 0578574 to da188ec Compare April 8, 2022 11:18
@costin-zaharia-sonarsource costin-zaharia-sonarsource marked this pull request as ready for review April 8, 2022 11:22
Copy link
Contributor

@csaba-sagi-sonarsource csaba-sagi-sonarsource left a comment

Choose a reason for hiding this comment

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

One additional performance improvement suggested.

@pavel-mikula-sonarsource
Copy link
Contributor

I've dismissed myself from the reviewers, I'm just a kibitzer here.

My threads are resolved now 🎉

@costin-zaharia-sonarsource costin-zaharia-sonarsource force-pushed the costin/SymbolReference-perf-opt branch from 03fd471 to bd51ce7 Compare April 11, 2022 09:01
Copy link
Contributor

@csaba-sagi-sonarsource csaba-sagi-sonarsource left a comment

Choose a reason for hiding this comment

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

Left the last two comments before approval.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

93.8% 93.8% Coverage
0.0% 0.0% Duplication

Copy link
Contributor

@csaba-sagi-sonarsource csaba-sagi-sonarsource left a comment

Choose a reason for hiding this comment

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

LGTM!

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.

Reduce the number of symbols retrieved by SymbolReferenceAnalyzer
3 participants