Skip to content

Commit 2016d60

Browse files
authored
Cleanup: Delete NGen of T (#9263)
Context The sole purpose of introducing the type seems to have been silencing a legacy code analyzer rule. The rule does not exist anymore / has not been brought over to Roslyn (dotnet/roslyn-analyzers#722) and it's now hurting performance, if anything. Types like HashSet<int> are part of the mscorlib native image and it's wasteful to duplicate the code in our binaries. The rest is handled by IBC/OptProf. Changes Made Deleted NGen and its uses. Testing Experimental insertion to confirm no regressions.
1 parent e493e7a commit 2016d60

File tree

9 files changed

+15
-71
lines changed

9 files changed

+15
-71
lines changed

src/Build/BackEnd/BuildManager/BuildManager.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public class BuildManager : INodePacketHandler, IBuildComponentHost, IDisposable
118118
/// <summary>
119119
/// Set of active nodes in the system.
120120
/// </summary>
121-
private readonly HashSet<NGen<int>> _activeNodes;
121+
private readonly HashSet<int> _activeNodes;
122122

123123
/// <summary>
124124
/// Event signalled when all nodes have shutdown.
@@ -128,7 +128,7 @@ public class BuildManager : INodePacketHandler, IBuildComponentHost, IDisposable
128128
/// <summary>
129129
/// Mapping of nodes to the configurations they know about.
130130
/// </summary>
131-
private readonly Dictionary<NGen<int>, HashSet<NGen<int>>> _nodeIdToKnownConfigurations;
131+
private readonly Dictionary<int, HashSet<int>> _nodeIdToKnownConfigurations;
132132

133133
/// <summary>
134134
/// Flag indicating if we are currently shutting down. When set, we stop processing packets other than NodeShutdown.
@@ -301,9 +301,9 @@ public BuildManager(string hostName)
301301
_buildSubmissions = new Dictionary<int, BuildSubmission>();
302302
_graphBuildSubmissions = new Dictionary<int, GraphBuildSubmission>();
303303
_noActiveSubmissionsEvent = new AutoResetEvent(true);
304-
_activeNodes = new HashSet<NGen<int>>();
304+
_activeNodes = new HashSet<int>();
305305
_noNodesActiveEvent = new AutoResetEvent(true);
306-
_nodeIdToKnownConfigurations = new Dictionary<NGen<int>, HashSet<NGen<int>>>();
306+
_nodeIdToKnownConfigurations = new Dictionary<int, HashSet<int>>();
307307
_unnamedProjectInstanceToNames = new Dictionary<ProjectInstance, string>();
308308
_nextUnnamedProjectId = 1;
309309
_componentFactories = new BuildComponentFactoryCollection(this);
@@ -2394,9 +2394,9 @@ private void HandleConfigurationRequest(int node, BuildRequestConfiguration unre
23942394

23952395
var response = new BuildRequestConfigurationResponse(unresolvedConfiguration.ConfigurationId, resolvedConfiguration.ConfigurationId, resolvedConfiguration.ResultsNodeId);
23962396

2397-
if (!_nodeIdToKnownConfigurations.TryGetValue(node, out HashSet<NGen<int>> configurationsOnNode))
2397+
if (!_nodeIdToKnownConfigurations.TryGetValue(node, out HashSet<int> configurationsOnNode))
23982398
{
2399-
configurationsOnNode = new HashSet<NGen<int>>();
2399+
configurationsOnNode = new HashSet<int>();
24002400
_nodeIdToKnownConfigurations[node] = configurationsOnNode;
24012401
}
24022402

@@ -2664,7 +2664,7 @@ private void PerformSchedulingActions(IEnumerable<ScheduleResponse> responses)
26642664
// of which nodes have had configurations specifically assigned to them for building. However, a node may
26652665
// have created a configuration based on a build request it needs to wait on. In this
26662666
// case we need not send the configuration since it will already have been mapped earlier.
2667-
if (!_nodeIdToKnownConfigurations.TryGetValue(response.NodeId, out HashSet<NGen<int>> configurationsOnNode) ||
2667+
if (!_nodeIdToKnownConfigurations.TryGetValue(response.NodeId, out HashSet<int> configurationsOnNode) ||
26682668
!configurationsOnNode.Contains(response.BuildRequest.ConfigurationId))
26692669
{
26702670
IConfigCache configCache = _componentFactories.GetComponent(BuildComponentType.ConfigCache) as IConfigCache;

src/Build/BackEnd/Components/BuildRequestEngine/BuildRequestEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ private void IssueBuildRequests(BuildRequestEntry issuingEntry, FullyQualifiedBu
11221122
lock (issuingEntry.GlobalLock)
11231123
{
11241124
var existingResultsToReport = new List<BuildResult>();
1125-
var unresolvedConfigurationsAdded = new HashSet<NGen<int>>();
1125+
var unresolvedConfigurationsAdded = new HashSet<int>();
11261126

11271127
foreach (FullyQualifiedBuildRequest request in newRequests)
11281128
{

src/Build/Evaluation/Evaluator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ internal class Evaluator<P, I, M, D>
115115
/// Dictionary of project full paths and a boolean that indicates whether at least one
116116
/// of their targets has the "Returns" attribute set.
117117
/// </summary>
118-
private readonly Dictionary<ProjectRootElement, NGen<bool>> _projectSupportsReturnsAttribute;
118+
private readonly Dictionary<ProjectRootElement, bool> _projectSupportsReturnsAttribute;
119119

120120
/// <summary>
121121
/// The Project Xml to be evaluated.
@@ -253,7 +253,7 @@ private Evaluator(
253253
_targetElements = new List<ProjectTargetElement>();
254254
_importsSeen = new Dictionary<string, ProjectImportElement>(StringComparer.OrdinalIgnoreCase);
255255
_initialTargetsList = new List<string>();
256-
_projectSupportsReturnsAttribute = new Dictionary<ProjectRootElement, NGen<bool>>();
256+
_projectSupportsReturnsAttribute = new Dictionary<ProjectRootElement, bool>();
257257
_projectRootElement = projectRootElement;
258258
_loadSettings = loadSettings;
259259
_maxNodeCount = maxNodeCount;
@@ -901,7 +901,7 @@ private void PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
901901
break;
902902
case ProjectTargetElement target:
903903
// Defaults to false
904-
_projectSupportsReturnsAttribute.TryGetValue(currentProjectOrImport, out NGen<bool> projectSupportsReturnsAttribute);
904+
_projectSupportsReturnsAttribute.TryGetValue(currentProjectOrImport, out bool projectSupportsReturnsAttribute);
905905

906906
_projectSupportsReturnsAttribute[currentProjectOrImport] = projectSupportsReturnsAttribute || (target.Returns != null);
907907
_targetElements.Add(target);

src/Build/Microsoft.Build.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@
8282
<Compile Include="..\Shared\IConstrainedEqualityComparer.cs">
8383
<Link>IConstrainedEqualityComparer.cs</Link>
8484
</Compile>
85-
<Compile Include="..\Shared\NGen.cs">
86-
<Link>SharedUtilities\NGen.cs</Link>
87-
</Compile>
8885
<Compile Include="..\Shared\PropertyParser.cs">
8986
<Link>BackEnd\Components\RequestBuilder\IntrinsicTasks\PropertyParser.cs</Link>
9087
</Compile>

src/Shared/NGen.cs

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/Tasks/ManifestUtil/ApplicationManifest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ private void ValidateReferencesForClickOnceApplication()
640640
{
641641
int t1 = Environment.TickCount;
642642
bool isPartialTrust = !TrustInfo.IsFullTrust;
643-
var targetPathList = new Dictionary<string, NGen<bool>>();
643+
var targetPathList = new Dictionary<string, bool>();
644644

645645
foreach (AssemblyReference assembly in AssemblyReferences)
646646
{

src/Tasks/ManifestUtil/Manifest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ private void ValidateReferences()
611611
return;
612612
}
613613

614-
var identityList = new Dictionary<string, NGen<bool>>();
614+
var identityList = new Dictionary<string, bool>();
615615
foreach (AssemblyReference assembly in AssemblyReferences)
616616
{
617617
if (assembly.AssemblyIdentity != null)

src/Tasks/Microsoft.Build.Tasks.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@
7373
<Compile Include="..\Shared\FileDelegates.cs">
7474
<Link>FileDelegates.cs</Link>
7575
</Compile>
76-
<Compile Include="..\Shared\NGen.cs">
77-
<Link>NGen.cs</Link>
78-
</Compile>
7976
<Compile Include="..\Shared\IConstrainedEqualityComparer.cs" />
8077
<Compile Include="..\Shared\PropertyParser.cs">
8178
<Link>PropertyParser.cs</Link>

src/Tasks/RedistList.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ internal sealed class RedistList
4848
/// When we check to see if an assembly is in this redist list we want to cache it so that if we ask again we do not
4949
/// have to re-scan bits of the redist list and do the assemblynameExtension comparisons.
5050
/// </summary>
51-
private readonly ConcurrentDictionary<AssemblyNameExtension, NGen<bool>> _assemblyNameInRedist = new ConcurrentDictionary<AssemblyNameExtension, NGen<bool>>(AssemblyNameComparer.GenericComparer);
51+
private readonly ConcurrentDictionary<AssemblyNameExtension, bool> _assemblyNameInRedist = new ConcurrentDictionary<AssemblyNameExtension, bool>(AssemblyNameComparer.GenericComparer);
5252

5353
/// <summary>
5454
/// AssemblyName to unified assemblyName. We make this kind of call a lot and also will ask for the same name multiple times.
@@ -431,7 +431,7 @@ public bool FrameworkAssemblyEntryInRedist(AssemblyNameExtension assemblyName)
431431
{
432432
ErrorUtilities.VerifyThrowArgumentNull(assemblyName, nameof(assemblyName));
433433

434-
if (!_assemblyNameInRedist.TryGetValue(assemblyName, out NGen<bool> isAssemblyNameInRedist))
434+
if (!_assemblyNameInRedist.TryGetValue(assemblyName, out bool isAssemblyNameInRedist))
435435
{
436436
string simpleName = GetSimpleName(assemblyName.Name);
437437
if (_simpleNameMap.TryGetValue(simpleName, out int index))

0 commit comments

Comments
 (0)