Skip to content

Reduce allocations in WithUsingNamespacesAndTypesBinder.GetForwardedToAssemblyInUsingNamespaces#76370

Merged
ToddGrun merged 1 commit intodotnet:mainfrom
ToddGrun:dev/toddgrun/GetForwardedToAssemblyInUsingNamespaces_Allocations
Dec 12, 2024
Merged

Reduce allocations in WithUsingNamespacesAndTypesBinder.GetForwardedToAssemblyInUsingNamespaces#76370
ToddGrun merged 1 commit intodotnet:mainfrom
ToddGrun:dev/toddgrun/GetForwardedToAssemblyInUsingNamespaces_Allocations

Conversation

@ToddGrun
Copy link
Contributor

This method shows up as 1.1% of allocations in the typing scenario in the csharp editing speedometer test. Of that, 0.6% is in the string.Concat call merging the Namespace, '.', and type name.

Instead of creating and passing this merged string to GetForwardedToAssembly, we can instead construct a MetadataTypeName to pass to that method. That struct can either be constructed using a fullname or a namespace/typename combination. In the caller where we are trying to get rid of the string concat, we can pass in the namespace/typename and avoid the concat operation completely.

The other caller to GetForwardedToAssembly also now passes in a MetadataTypeName, but it's constructed from the fullname as that method used to do itself before taking in the MetadataTypeName.

image

…oAssemblyInUsingNamespaces

This method shows up as 1.1% of allocations in the typing scenario in the csharp editing speedometer test. Of that, 0.6% is in the string.Concat call merging the Namespace, '.', and type name.

Instead of creating and passing this merged string to GetForwardedToAssembly, we can instead construct a MetadataTypeName to pass to that method. That struct can either be constructed using a fullname or a namespace/typename combination.  In the caller where we are trying to get rid of the string concat, we can pass in the namespace/typename and avoid the concat operation completely.

The other caller to GetForwardedToAssembly also now passes in a MetadataTypeName, but it's constructed from the fullname as that method used to do itself before taking in the MetadataTypeName.
@ToddGrun ToddGrun requested a review from a team as a code owner December 11, 2024 06:53
@ghost ghost added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Dec 11, 2024
@ToddGrun
Copy link
Contributor Author

@dotnet/roslyn-compiler ptal

@jaredpar jaredpar removed the untriaged Issues and PRs which have not yet been triaged by a lead label Dec 11, 2024
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.

6 participants