Skip to content
This repository has been archived by the owner on Oct 30, 2019. It is now read-only.

Commit

Permalink
Reduce VM usage in emit tests
Browse files Browse the repository at this point in the history
This change reduces the VM used and memory allocated in the emit
tests by moving the WinRT tests to their own DLL and removing
the extra mscorlib reference.

The cause of most of the allocations in the Emit unit tests was
serializing the WinRT assemblies across app domains. There were
three reasons the DLLs needed to be serialized:

1) PeVerify currently requires a separate app domain to be used if
   any of the references of the assembly to be verified have already
   been loaded into the current app domain and have a different MVID.

2) The WinRT tests all use a separate version of mscorlib, so they
   will all reference an assembly with a different MVID than the one
   loaded.

3) Most of the WinRT tests were accidentally pulling two references
   to mscorlib, also always leading to a conflict.

All of these issues should be resolved. The CSharp.Emit unit tests
now allocated 400 MB less and have > 100 MB smaller peak VM.

Fixes #386.
  • Loading branch information
agocke committed Feb 14, 2015
1 parent cb238ad commit 3fcf7ba
Show file tree
Hide file tree
Showing 19 changed files with 286 additions and 269 deletions.
1 change: 1 addition & 0 deletions BuildAndTest.proj
Expand Up @@ -66,6 +66,7 @@

<TestAssemblies Include="Binaries\Debug\Roslyn.Compilers.CSharp.CommandLine.UnitTests.dll" />
<TestAssemblies Include="Binaries\Debug\Roslyn.Compilers.CSharp.Emit.UnitTests.dll" />
<TestAssemblies Include="Binaries\Debug\Roslyn.Compilers.CSharp.WinRT.UnitTests.dll" />
<TestAssemblies Include="Binaries\Debug\Roslyn.Compilers.CSharp.Semantic.UnitTests.dll" />
<TestAssemblies Include="Binaries\Debug\Roslyn.Compilers.CSharp.Syntax.UnitTests.dll" />
<TestAssemblies Include="Binaries\Debug\Roslyn.Compilers.CSharp.Symbol.UnitTests.dll" />
Expand Down
1 change: 1 addition & 0 deletions src/Compilers/CSharp/Portable/CSharpCodeAnalysis.csproj
Expand Up @@ -867,6 +867,7 @@
<InternalsVisibleToTest Include="Roslyn.Compilers.UnitTests" />
<InternalsVisibleToTest Include="Roslyn.Compilers.CSharp.CommandLine.UnitTests" />
<InternalsVisibleToTest Include="Roslyn.Compilers.CSharp.Emit.UnitTests" />
<InternalsVisibleToTest Include="Roslyn.Compilers.CSharp.WinRT.UnitTests" />
<InternalsVisibleToTest Include="Roslyn.Compilers.CSharp.EnC.UnitTests" />
<InternalsVisibleToTest Include="Roslyn.Compilers.CSharp.Semantic.UnitTests" />
<InternalsVisibleToTest Include="Roslyn.Compilers.CSharp.Symbol.UnitTests" />
Expand Down
3 changes: 1 addition & 2 deletions src/Compilers/CSharp/Test/Emit/CSharpCompilerEmitTest.csproj
Expand Up @@ -144,8 +144,6 @@
<Compile Include="CodeGen\SwitchTests.cs" />
<Compile Include="CodeGen\UnsafeTests.cs" />
<Compile Include="CodeGen\WinMdDelegateTests.cs" />
<Compile Include="CodeGen\WinMdEventTests.cs" />
<Compile Include="CodeGen\WinRTCollectionTests.cs" />
<Compile Include="Emit\CompilationEmitTests.cs" />
<Compile Include="Emit\DeterministicTests.cs" />
<Compile Include="Emit\EditAndContinue\AssemblyReferencesTests.cs" />
Expand Down Expand Up @@ -198,6 +196,7 @@
<EmbeddedResource Include="Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
Expand Down
Expand Up @@ -162,9 +162,6 @@
<Compile Include="Symbols\Metadata\PE\TypeAccessibility.cs" />
<Compile Include="Symbols\Metadata\PE\TypeForwarders.cs" />
<Compile Include="Symbols\Metadata\PE\TypeKindTests.cs" />
<Compile Include="Symbols\Metadata\WinMdDumpTest.cs" />
<Compile Include="Symbols\Metadata\WinMdEventTests.cs" />
<Compile Include="Symbols\Metadata\WinMdMetadataTests.cs" />
<Compile Include="Symbols\MethodEqualityTests.cs" />
<Compile Include="Symbols\MissingSpecialMember.cs" />
<Compile Include="Symbols\MockAssemblySymbol.cs" />
Expand Down
99 changes: 99 additions & 0 deletions src/Compilers/CSharp/Test/WinRT/CSharpWinRTTest.csproj
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="Settings">
<Import Project="..\..\..\..\Tools\Microsoft.CodeAnalysis.Toolset.Open\Targets\VSL.Settings.targets" />
<Import Project="..\..\..\..\..\build\VSL.Settings.Closed.targets" />
</ImportGroup>
<PropertyGroup>
<NonShipping>true</NonShipping>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{FCFA8808-A1B6-48CC-A1EA-0B8CA8AEDA8E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.CodeAnalysis.CSharp.UnitTests.CodeGen</RootNamespace>
<AssemblyName>Roslyn.Compilers.CSharp.WinRT.UnitTests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>46858cd2</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="CodeGen\WinMdEventTests.cs" />
<Compile Include="CodeGen\WinRTCollectionTests.cs" />
<Compile Include="Metadata\WinMdDumpTest.cs" />
<Compile Include="Metadata\WinMdEventTests.cs" />
<Compile Include="Metadata\WinMdMetadataTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Test\Utilities\TestUtilities.csproj">
<Project>{76c6f005-c89d-4348-bb4a-391898dbeb52}</Project>
<Name>TestUtilities</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Core\Portable\CodeAnalysis.csproj">
<Project>{1ee8cad3-55f9-4d91-96b2-084641da9a6c}</Project>
<Name>CodeAnalysis</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Test\Resources\Core\CompilerTestResources.vbproj">
<Project>{7fe6b002-89d8-4298-9b1b-0b5c247dd1fd}</Project>
<Name>CompilerTestResources</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Test\Utilities\Core2\CompilerTestUtilities2.csproj">
<Project>{f7712928-1175-47b3-8819-ee086753dee2}</Project>
<Name>CompilerTestUtilities2</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Test\Utilities\CSharp\CSharpCompilerTestUtilities.csproj">
<Project>{4371944a-d3ba-4b5b-8285-82e5ffc6d1f9}</Project>
<Name>CSharpCompilerTestUtilities</Name>
</ProjectReference>
<ProjectReference Include="..\..\Portable\CSharpCodeAnalysis.csproj">
<Project>{b501a547-c911-4a05-ac6e-274a50dff30e}</Project>
<Name>CSharpCodeAnalysis</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.CodeAnalysis.Test.Resources.Proprietary">
<HintPath>..\..\..\..\..\packages\Microsoft.CodeAnalysis.Test.Resources.Proprietary.1.0.0-rc1-20150208-02\lib\net45\Microsoft.CodeAnalysis.Test.Resources.Proprietary.dll</HintPath>
</Reference>
<Reference Include="System.Collections.Immutable, Version=1.1.33.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\packages\System.Collections.Immutable.1.1.33-beta\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
</Reference>
<Reference Include="System.Reflection.Metadata, Version=1.0.18.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\packages\System.Reflection.Metadata.1.0.18-beta\lib\portable-net45+win8\System.Reflection.Metadata.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="xunit, Version=1.9.2.1705, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\packages\xunit.1.9.2\lib\net20\xunit.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ImportGroup Label="Targets">
<Import Project="..\..\..\..\Tools\Microsoft.CodeAnalysis.Toolset.Open\Targets\VSL.Imports.targets" />
<Import Project="..\..\..\..\..\build\VSL.Imports.Closed.targets" />
<Import Project="..\..\..\..\..\build\Roslyn.Toolsets.Xunit.targets" />
</ImportGroup>
</Project>
Expand Up @@ -173,7 +173,7 @@ class C
event System.Action E;
}
";
var verifier = CompileAndVerify(source, options: TestOptions.ReleaseWinMD, emitOptions: TestEmitters.RefEmitBug, additionalRefs: WinRtRefs);
var verifier = CompileAndVerifyWinRt(source, options: TestOptions.ReleaseWinMD, emitOptions: TestEmitters.RefEmitBug);

verifier.VerifyIL("C.E.add", @"
{
Expand Down Expand Up @@ -209,7 +209,7 @@ class C
static event System.Action<int> E;
}
";
var verifier = CompileAndVerify(source, options: TestOptions.ReleaseWinMD, emitOptions: TestEmitters.RefEmitBug, additionalRefs: WinRtRefs);
var verifier = CompileAndVerifyWinRt(source, options: TestOptions.ReleaseWinMD, emitOptions: TestEmitters.RefEmitBug);

verifier.VerifyIL("C.E.add", @"
{
Expand Down Expand Up @@ -273,7 +273,7 @@ static void Action()
}
}
";
var verifier = CompileAndVerify(source, options: TestOptions.ReleaseWinMD, emitOptions: TestEmitters.RefEmitBug, additionalRefs: WinRtRefs);
var verifier = CompileAndVerifyWinRt(source, options: TestOptions.ReleaseWinMD, emitOptions: TestEmitters.RefEmitBug);

verifier.VerifyIL("D.InstanceAdd", @"
{
Expand Down Expand Up @@ -366,7 +366,7 @@ static void Action()
}
}
";
var verifier = CompileAndVerify(source, options: TestOptions.ReleaseWinMD, emitOptions: TestEmitters.RefEmitBug, additionalRefs: WinRtRefs);
var verifier = CompileAndVerifyWinRt(source, options: TestOptions.ReleaseWinMD, emitOptions: TestEmitters.RefEmitBug);

verifier.VerifyIL("C.InstanceAssign", @"
{
Expand Down Expand Up @@ -455,7 +455,7 @@ static void Action()
}
}
";
var verifier = CompileAndVerify(source, options: TestOptions.ReleaseWinMD, emitOptions: TestEmitters.RefEmitBug, additionalRefs: WinRtRefs);
var verifier = CompileAndVerifyWinRt(source, options: TestOptions.ReleaseWinMD, emitOptions: TestEmitters.RefEmitBug);

verifier.VerifyIL("C.InstanceInvoke", @"
{
Expand Down

0 comments on commit 3fcf7ba

Please sign in to comment.