Skip to content

Conversation

@genlu
Copy link
Member

@genlu genlu commented Sep 6, 2023

@genlu genlu requested review from a team as code owners September 6, 2023 22:04
@ghost ghost added Area-Analyzers untriaged Issues and PRs which have not yet been triaged by a lead labels Sep 6, 2023
@genlu genlu requested a review from davkean September 6, 2023 22:06
builder[swapIndex] = builder[i];
}

builder.Free();
Copy link
Member

Choose a reason for hiding this comment

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

Not loving that this whole algorithm was written out twice.

Copy link
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

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

I do wonder a bit about whether this will fully fix contention (I think it may be likely that users don't have that many analyzer assemblies, and the analyzers within an assembly will share some number of helper types, so randomizing may help a bit, but still have contention in the shared helper types), but I'm willing to give it a try and see if it helps.

@genlu
Copy link
Member Author

genlu commented Sep 6, 2023

@dotnet/roslyn-compiler Could I have another compiler review please? Thanks!

@davkean
Copy link
Member

davkean commented Sep 7, 2023

I do wonder a bit about whether this will fully fix contention (I think it may be likely that users don't have that many analyzer assemblies, and the analyzers within an assembly will share some number of helper types, so randomizing may help a bit, but still have contention in the shared helper types), but I'm willing to give it a try and see if it helps.

I'm seeing 4 types of contention:

  • Static constructors
  • JITing (the same methods)
  • Type loading
  • Assembly loading

I'm fairly hopeful that randomization will have a pretty good impact on the top two, unsure about the last two yet.

Update: Spin waiting contention (ie CPU) was in ~60% of all solution load traces, and that doesn't factor in in sync (blocked) time.

@genlu
Copy link
Member Author

genlu commented Sep 7, 2023

@333fred Could you pls take another look? Pushed additional change to ensure deterministic (here for more details)

}

return analyzers.ToImmutable();
analyzers.Sort(static (x, y) => string.Compare(x.typeName, y.typeName, StringComparison.OrdinalIgnoreCase));
Copy link
Member Author

Choose a reason for hiding this comment

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

Since we are sorting here, I changed the type of analyzerTypeNames to ImmutableHashSet from ImmutableSortedSet

@genlu genlu merged commit fd01491 into dotnet:main Sep 8, 2023
@genlu genlu deleted the RandomAnalyzer branch September 8, 2023 17:25
@ghost ghost added this to the Next milestone Sep 8, 2023
@Cosifne Cosifne modified the milestones: Next, 17.8 P3 Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Analyzers untriaged Issues and PRs which have not yet been triaged by a lead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants