-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Mono]: Reduce Mono AOT cross compiler x64 memory footprint. (#97096)
Building .net8 S.P.C using Mono AOT cross compiler in full AOT consumes a large amount of memory (up to 6 GB). This is mainly due to generated LLVM module not being optimized at all while kept in memory during full module generation. Mono x64 also lacks support for several intrinsics as well as Vector 256/512 that in turn leads to massive inlining of intrinsics functions generating a very large LLVM module, where majority of this code ends up as dead code due to IsSupported/IsHardwareAccelerated returning false. The follow commit adjusts several things that will bring down the memory usage, compiling .net8/.net9 Mono S.P.C on x64 Windows from 6 GB down to ~750 MB. * Use PSNE implementations on intrinsics not supported on Mono. * Add ILLinker substitutions for intrinsics not supported on Mono. Enables ILLinker to do dead code elimination, reduce code to AOT compile. * Prevent aggressive inlining for a couple of unsupported intrinsics types making sure we don't end up with excessive inlining, exploding code size. * Run a couple of LLVM optimization passes on each generated method doing early code simplification and dead code elimination during LLVM module generation. * Explicit SN_get_IsHardwareAccelerated/SN_get_IsSupported intrinsics implementation for all unsupported Mono x64 SIMD intrinsics. * Fixed numerous memory leaks in Mono AOT cross compiler code. * Fix a couple of sequence points free after use errors. * Fix an anonymous struct build warning triggering build error for LLVM enabled cross compiler on Windows. --------- Co-authored-by: Zoltan Varga <[email protected]>
- Loading branch information
1 parent
3e9cce6
commit a79c62d
Showing
8 changed files
with
182 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/mono/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Intrinsics.Vectors.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<linker> | ||
<assembly fullname="System.Private.CoreLib"> | ||
<type fullname="System.Runtime.Intrinsics.Vector256"> | ||
<method signature="System.Boolean get_IsHardwareAccelerated()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Runtime.Intrinsics.Vector512"> | ||
<method signature="System.Boolean get_IsHardwareAccelerated()" body="stub" value="false" /> | ||
</type> | ||
</assembly> | ||
</linker> |
79 changes: 79 additions & 0 deletions
79
src/mono/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Intrinsics.x86.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<linker> | ||
<assembly fullname="System.Private.CoreLib"> | ||
<type fullname="System.Runtime.Intrinsics.X86.Avx"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Runtime.Intrinsics.X86.Avx/X64"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Runtime.Intrinsics.X86.Avx2"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Runtime.Intrinsics.X86.Avx2/X64"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Runtime.Intrinsics.X86.Avx512BW"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Runtime.Intrinsics.X86.Avx512BW/VL"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Runtime.Intrinsics.X86.Avx512BW/X64"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Runtime.Intrinsics.X86.Avx512CD"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Runtime.Intrinsics.X86.Avx512CD/VL"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Runtime.Intrinsics.X86.Avx512CD/X64"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Runtime.Intrinsics.X86.Avx512DQ"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Runtime.Intrinsics.X86.Avx512DQ/VL"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Runtime.Intrinsics.X86.Avx512DQ/X64"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Runtime.Intrinsics.X86.Avx512F"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Runtime.Intrinsics.X86.Avx512F/VL"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Runtime.Intrinsics.X86.Avx512F/X64"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Runtime.Intrinsics.X86.Avx512Vbmi"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Runtime.Intrinsics.X86.Avx512Vbmi/VL"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Runtime.Intrinsics.X86.Avx512Vbmi/X64"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Runtime.Intrinsics.X86.AvxVnni"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Runtime.Intrinsics.X86.AvxVnni/X64"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Runtime.Intrinsics.X86.Fma"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Runtime.Intrinsics.X86.Fma/X64"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Runtime.Intrinsics.X86.X86Serialize"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Runtime.Intrinsics.X86.X86Serialize/X64"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
</assembly> | ||
</linker> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters