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

Search less files when searching in global suppressions. #57890

Merged
merged 1 commit into from
Nov 20, 2021

Conversation

CyrusNajmabadi
Copy link
Member

The current approach to finding FAR results in global suppressions is to make all documents with jsut a global attribute in it eligible for searching. This means any doc that has a [assembly: ...] attribute it in is searched (regardless of what attribute it actually is).

This is doubly problematic as to search the doc we need the semantic-model for it, which requires getting the compilation for that project, which requires parsing all the files in the project. In a project like roslyn, we have enough of these attributes scattered everywhere to make it so that we effectively have to create most of the compilations for all our projects just to get no results.

This PR changes our logic to only search docs that actually have a global attribute whose name could match SuppressMessageAttribute. This means most projects have no hits and we produce no compilations.

--

Note: this might mean we might something. For example, if the user has a global alias to SuppressMessageAttribute. But at that point, things are so esoteric i don't think we care at all, and the perf win here is substantive enough to warrant it. If we do want to support such a corner case in the future, we always could, by using a similar mechanism we have in other places where we keep track if alias names and check those. But for this the complexit is likely never going to be worth it given how this should not arise in practice.

@@ -16,7 +16,7 @@ namespace Microsoft.CodeAnalysis.FindSymbols
internal sealed partial class SyntaxTreeIndex : IObjectWritable
{
private const string PersistenceName = "<SyntaxTreeIndex>";
private static readonly Checksum SerializationFormatChecksum = Checksum.Create("25");
private static readonly Checksum SerializationFormatChecksum = Checksum.Create("26");
Copy link
Member Author

Choose a reason for hiding this comment

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

our binary format is the same, but we cannot use any existing caches as the new and old data are not compatible with each other.

name = right;
}

if (!syntaxFacts.IsIdentifierName(name))
Copy link
Contributor

Choose a reason for hiding this comment

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

is this even possible with GetNameOfAttribute?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes. [A.B<int>()]

@CyrusNajmabadi CyrusNajmabadi merged commit 897b786 into dotnet:main Nov 20, 2021
@ghost ghost added this to the Next milestone Nov 20, 2021
@allisonchou allisonchou modified the milestones: Next, 17.1.P2 Nov 30, 2021
@CyrusNajmabadi CyrusNajmabadi deleted the farGlobalSuppress branch February 1, 2022 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants