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
|
@ -111,7 +111,7 @@ namespace Microsoft.DotNet.Cli
|
|||
command = "help";
|
||||
}
|
||||
|
||||
int exitCode;
|
||||
int exitCode;
|
||||
Func<string[], int> builtIn;
|
||||
if (s_builtIns.TryGetValue(command, out builtIn))
|
||||
{
|
||||
|
@ -175,16 +175,16 @@ namespace Microsoft.DotNet.Cli
|
|||
{
|
||||
return (shortName != null && candidate.Equals("-" + shortName)) || (longName != null && candidate.Equals("--" + longName));
|
||||
}
|
||||
|
||||
|
||||
private static string GetCommitSha()
|
||||
{
|
||||
var versionFile = DotnetFiles.VersionFile;
|
||||
|
||||
|
||||
if (File.Exists(versionFile))
|
||||
{
|
||||
return File.ReadLines(versionFile).FirstOrDefault()?.Substring(0, 10);
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue