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

Reduce the number of memory allocations in SA1404 (CodeAnalysisSuppressionMustHaveJustification) #1157

Merged
merged 2 commits into from Aug 8, 2015

Conversation

sharwell
Copy link
Member

@sharwell sharwell commented Aug 8, 2015

  • Avoid semantic analysis when simple name analysis will work. This step reuses cached information from SA1121 (UseBuiltInTypeAlias).
  • Avoid calling GetTypeByMetadataName for every attribute in the compilation. Instead, this method is called once per compilation and cached.

When analyzing StyleCopAnalyzers, SA1404 was the most expensive analyzer in terms of both number of memory allocations and total bytes allocated. The following summary shows the improvement:

Commit Inclusive Allocations Inclusive Bytes
6e92da9 545065 18977452
4ae9b5e 113 10304

Edit: Analysis now run with the instrumenting profiler to verify accuracy.

…ssionMustHaveJustification)

* Avoid semantic analysis when simple name analysis will work. This step
  reuses cached information from SA1121 (UseBuiltInTypeAlias).
* Avoid calling `GetTypeByMetadataName` for every attribute in the
  compilation. Instead, this method is called once per compilation and
  cached.
@pdelvo
Copy link
Member

pdelvo commented Aug 8, 2015

Thats a huge improvement! I just looked at our unit tests for SA1404 and it does not have any test that uses aliases. We probably want some.

@sharwell
Copy link
Member Author

sharwell commented Aug 8, 2015

Added some tests

@pdelvo
Copy link
Member

pdelvo commented Aug 8, 2015

👍

@sharwell sharwell assigned pdelvo and unassigned sharwell Aug 8, 2015
sharwell added a commit that referenced this pull request Aug 8, 2015
Reduce the number of memory allocations in SA1404 (CodeAnalysisSuppressionMustHaveJustification)
@sharwell sharwell merged commit b242672 into DotNetAnalyzers:master Aug 8, 2015
@sharwell sharwell deleted the sa1404-memory branch August 8, 2015 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants