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

Test allocations #75171

Merged
merged 2 commits into from
Sep 19, 2024
Merged

Test allocations #75171

merged 2 commits into from
Sep 19, 2024

Conversation

jaredpar
Copy link
Member

Continuing to work on unnecessary allocations in our unit tests

Continuing to work on unnecessary allocations in our unit tests
@jaredpar jaredpar requested a review from a team as a code owner September 19, 2024 17:11
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Sep 19, 2024
@@ -12384,7 +12384,7 @@ void binaryOperator(string op, string leftType, string rightType, string expecte

if (expectedDiagnostics.Length == 0)
{
CompileAndVerify(comp);
CompileAndVerify(comp, emitOptions: EmitOptions.Default);
Copy link
Member Author

Choose a reason for hiding this comment

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

By default CompileAndVerify embeds portable PDBs and the sheer number of tests here was causing that allocate 100MB of unnecessary byte[].

@@ -13,6 +13,7 @@
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a significant source of redundant byte[] allocations.

/// <summary>
/// This is the full set of references provided by default on the .NET Framework TFM
/// </summary>
/// <remarks>
/// Need to special case tuples until we move to net472
/// </remarks>
public static ImmutableArray<MetadataReference> References { get; } = [.. Net461.References.All, Net461.ExtraReferences.SystemValueTuple];
public static ImmutableArray<MetadataReference> References
Copy link
Member Author

Choose a reason for hiding this comment

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

There are a number of tests that call say NetFramework.mscorlib. When this was a static initializer that realized all these values when they didn't really need to be. This is only a savings in certain silces of our tests but it's a significant one in them.

@jaredpar
Copy link
Member Author

@dotnet/roslyn-compiler PTAL

@jaredpar jaredpar merged commit 37ba9ee into dotnet:main Sep 19, 2024
21 of 24 checks passed
@jaredpar jaredpar deleted the test-alloc1 branch September 19, 2024 19:12
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Sep 19, 2024
Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM (commit 2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers 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.

3 participants