Memory usage improvements in build (#2626)
* Use a WorkspaceContext in dotnet-build to cache project data across multiple compilations in a single build action * Dramatically reduce string and object duplication by introducing a "Symbol Table" that shares instances of NuGetVersion, NuGetFramework, VersionRange and string across multiple lock-file parses Test Results: * Testing was done by compiling Microsoft.AspNetCore.Mvc (and it's dependencies) and taking memory snapshots after each compilation in dotMemory * We used to allocate ~3MB and deallocate ~2.5MB on EACH compilation in a single build action. This has been reduced to ~120KB allocated/deallocated * After introducing WorkspaceContext, total memory usage spiked from 6MB across the whole build action to about 13MB, introducing the symbol table dropped it back to about 5-6MB.
This commit is contained in:
parent
80df3688b1
commit
ef0ca39da1
42 changed files with 496 additions and 268 deletions
|
@ -506,13 +506,13 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
|||
var testProjectRoot = Path.Combine(RepoRoot, "TestAssets", "ProjectModelServer", "MSBuildReferencesProjects", "ValidCase01");
|
||||
foreach (var classLibrary in classLibraries)
|
||||
{
|
||||
dependencies.RetrieveDependency(classLibrary)
|
||||
.AssertProperty("Type", LibraryType.MSBuildProject.ToString())
|
||||
.AssertProperty("Path", NormalizePathString(Path.Combine(testProjectRoot, classLibrary, $"{classLibrary}.csproj")))
|
||||
.AssertProperty<bool>("Resolved", true)
|
||||
.AssertProperty("Name", classLibrary)
|
||||
.AssertProperty<JArray>("Errors", array => array.Count == 0)
|
||||
.AssertProperty<JArray>("Warnings", array => array.Count == 0);
|
||||
var dependency = dependencies.RetrieveDependency(classLibrary);
|
||||
dependency.AssertProperty("Type", LibraryType.MSBuildProject.ToString());
|
||||
dependency.AssertProperty("Path", NormalizePathString(Path.Combine(testProjectRoot, classLibrary, $"{classLibrary}.csproj")));
|
||||
dependency.AssertProperty<bool>("Resolved", true);
|
||||
dependency.AssertProperty("Name", classLibrary);
|
||||
dependency.AssertProperty<JArray>("Errors", array => array.Count == 0);
|
||||
dependency.AssertProperty<JArray>("Warnings", array => array.Count == 0);
|
||||
}
|
||||
|
||||
var references = messages.RetrieveSingleMessage(MessageTypes.References)
|
||||
|
@ -632,12 +632,12 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
|||
afterDependencies.RetrieveDependency("ClassLibrary3");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void TestMscorlibLibraryDuplication()
|
||||
{
|
||||
var projectPath = Path.Combine(RepoRoot, "TestAssets", "ProjectModelServer", "MscorlibLibraryDuplication");
|
||||
|
||||
|
||||
using (var server = new DthTestServer(_loggerFactory))
|
||||
using (var client = new DthTestClient(server, _loggerFactory))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue