Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improvement] Removed all usage of reflection, enabled trimming on UWP, improved memory usage when compiling .NET Native #184

Merged
merged 27 commits into from
Jul 22, 2022

Conversation

Arlodotexe
Copy link
Owner

@Arlodotexe Arlodotexe commented Jun 30, 2022

Overview

This PR attempts to fix an issue where .NET Native throws errors when building release on a Azure DevOps hosted agent.

We've been seeing various errors, mostly "Out of memory" and "Internal compiler error". This PR attempts to fix them.

Progress towards #170

Checklist

This PR meets the following requirements:

  • Tested and contains NO breaking changes or known regressions.
  • Tested with the upstream branch merged in.
  • Tests have been added for bug fixes / features (or this option is not applicable)
  • All new code has been documented (or this option is not applicable)
  • Headers have been added to all new source files (or this option is not applicable)

Additional info

Not provided

@Arlodotexe Arlodotexe added tooling Related to tooling used to create, host or collaborate on the project hotfix Small change to correct a released regression asap app Relevant to the Strix Music App labels Jun 30, 2022
@Arlodotexe
Copy link
Owner Author

Arlodotexe commented Jun 30, 2022

If the Build Validation doesn't succeed on the first try then the fix was not successful.
Once we get a successful run, I'll be running the build validation multiple times against this branch to make sure this is actually fixed.

@Arlodotexe
Copy link
Owner Author

Relevant error log:

image

@Arlodotexe
Copy link
Owner Author

Arlodotexe commented Jul 11, 2022

It would appear that the problem has been slightly mitigated. The issue still appears sometimes, but it's much more likely to succeed than fail now, which is enough to usually pass the CI with a max of 3 retries.

@Arlodotexe
Copy link
Owner Author

Arlodotexe commented Jul 12, 2022

I've also set the pipeline to never retry, so now we should know if it succeeded in less than 20 minutes

@Arlodotexe
Copy link
Owner Author

Arlodotexe commented Jul 13, 2022

We've managed to fix the fatal error N1002: Out of Memory error. (updated: see below)

But we're still pretty consistently getting error : ILT0005: and Error : Internal Compiler Error when the build does fail.
image

These might contain some useful information:

@Arlodotexe
Copy link
Owner Author

Arlodotexe commented Jul 14, 2022

After 3 more runs, we've managed to get several additional errors. These all seem to always be paired to the existing ILT0005 message, never appearing on their own, sometimes not appearing at all.

This occured while scanning the methods for the MDIL compiler:

fatal error N1002: Out of Memory (TaskId:893)

These occurred after successfully generating the StrixMusic.mdilexe, still failing the GenerateMDILGlobalAnalysis task.

Error: NUTC1056:Internal Compiler Error: 0x8007000e. Error encountered
NUTC300F:Internal Compiler Error: Native compilation failed due to out of memory error

So far, in an attempt to curb these issues, we've enabled these properties:

    <Use64BitCompiler>true</Use64BitCompiler>
    <PreferredToolArchitecture>x64</PreferredToolArchitecture>

    <SingleThreadNUTC>true</SingleThreadNUTC>
    <UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
    <EnableGatekeeperAnalysis>true</EnableGatekeeperAnalysis>
    <ShortcutGenericAnalysis>true</ShortcutGenericAnalysis> <!-- Can help stop runaway analysis of generic types and reduce overall generation requirements. -->
    <OutOfProcPDB>true</OutOfProcPDB> <!-- Opt-in to generate PDB's out of process -->

It should be noted that Azure DevOps machines (where these are failing) only get 7Gb of RAM and 2 processor cores.

@Arlodotexe
Copy link
Owner Author

Arlodotexe commented Jul 14, 2022

I've used this to create a repro so the .NET Native team can take a look:
https://github.com/dotnet/core/blob/main/Documentation/ilcRepro.md

The files have been uploaded to ipfs:

Gateway link CID
netnativerepro-ARM.zip QmQpxWTHjmQon6HzBT8ymwbjqhpsLY2aQnApadQ6kd3Z7D
netnativerepro-x64.zip QmavC7xzzQDQpeaknBz5Fs5DwpEpzey7JYJU5UvGR9TyZG
netnativerepro-x86.zip QmcgFgsTFGmrDDpf7n6fjD9JyVG8HyM2sVBuFYw6t2chKF

@Arlodotexe Arlodotexe changed the title [fix] Fixed sporadic release mode failures in CI [improvement] Enabled trimming on UWP, improved memory usage when compiling .NET Native Jul 22, 2022
@Arlodotexe
Copy link
Owner Author

Arlodotexe commented Jul 22, 2022

We've done everything we possibly can, and we'll need to wait for the .NET Native team to get back to us before we can do more.

That in mind, this PR does contain a number of useful improvements that we'll want to keep. We'll be merging this in and closing this off, saving the full fix for later.

@Arlodotexe Arlodotexe merged commit e7d2fae into master Jul 22, 2022
@Arlodotexe Arlodotexe deleted the fix/sporadic-ci-release-mode-failures branch July 22, 2022 23:04
@Arlodotexe Arlodotexe changed the title [improvement] Enabled trimming on UWP, improved memory usage when compiling .NET Native [improvement] Removed all usage of reflection, enabled trimming on UWP, improved memory usage when compiling .NET Native Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app Relevant to the Strix Music App hotfix Small change to correct a released regression asap tooling Related to tooling used to create, host or collaborate on the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants