Skip to content

Conversation

@jaredpar
Copy link
Member

@jaredpar jaredpar commented Mar 9, 2023

This fixes the following issues in Rebuild validation

  1. Adds back <PlatformTarget>AnyCPU</PlatformTarget> so the exe runs under x64 in CI. Running in x86 in CI is putting us right up against the memory boundary and sometimes results in crashes.
  2. Changes LocalReferenceResolver such that directories are only enumerated twice (once for exe and one for dll). In the past every new name request caused the entire directory set to be walked again. This change saved ~8 seconds on our CI runs.
  3. When there is a misc error record it in the build artifacts instead of silently failing.

Related: #52800

This fixes the following issues in Rebuild validation

1. Adds back `<PlatformTarget>AnyCPU</PlatformTarget>` so the exe runs
   under x64 in CI. Running in x86 in CI is putting us right up against
   the memory boundary and sometimes results in crashes.
2. Changes `LocalReferenceResolver` such that directories are only
   enumerated twice (once for exe and one for dll). In the past every
   new name request caused the entire directory set to be walked again.
   This change saved ~8 seconds on our CI runs.
3. When there is a misc error record it in the build artifacts instead
   of silently failing.

Related: dotnet#52800
@jaredpar jaredpar requested a review from a team as a code owner March 9, 2023 00:22
@jaredpar
Copy link
Member Author

jaredpar commented Mar 9, 2023

@dotnet/roslyn-compiler, @RikkiGibson, @jjonescz PTAL


foreach (var directory in _indexDirectories)
using var _ = _logger.BeginScope($"Populating {fileName}");
var assemblyInfoList = new List<AssemblyInfo>();
Copy link
Member

Choose a reason for hiding this comment

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

nit: would passing a size hint be helpful here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Usually I only pass a size hint when I know what the size will be. In this case it's hard to know. If you watch the output you'll notice that there are hundreds and hundreds of R2R images that end up getting searched. Using capacity here would end up causing the list to overallocate for a lot of System.* DLLs.


_nameMap[metadataReferenceInfo.FileName] = list;
return _mvidMap.TryGetValue(metadataReferenceInfo.ModuleVersionId, out assemblyInfo);
_nameMap[fileName] = assemblyInfoList;
Copy link
Member

Choose a reason for hiding this comment

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

I guess the reason we don't do this at the same time we enumerate directories is, this step is more expensive and we don't expect to be asked about every last .exe or .dll? Is that right?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's correct. Enumerating the directories is expensive so we try to do it the minimum number of times. Essentially it's cheaper to enumerate *.dll once and record the locations vs. enumerate fileName.dll for each individual request. The enumeration itself is very expensive given the number of dirs that we search so do it once and save.

But delay actually reading the files off disk until we're asked to do so cause we end up indexing a lot more files than we actually need to read.

@jaredpar jaredpar merged commit 7f00c15 into dotnet:main Mar 14, 2023
@jaredpar jaredpar deleted the rebuild branch March 14, 2023 18:57
@ghost ghost added this to the Next milestone Mar 14, 2023
@allisonchou allisonchou modified the milestones: Next, 17.6 P3 Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants