From ba2d420d839f0cf54e60feb8df2f4cf7165ed955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Thu, 9 Mar 2023 11:41:27 +0900 Subject: [PATCH 1/5] Try reducing memory pressure during object writing --- .../Compiler/DependencyAnalysis/ObjectWriter.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs index b42db28d6f2445..cd3ca61f27a5ec 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs @@ -1150,7 +1150,13 @@ public static void EmitObject(string objectFilePath, IReadOnlyCollection Date: Thu, 9 Mar 2023 11:49:42 +0900 Subject: [PATCH 2/5] Update ObjectWriter.cs --- .../Compiler/DependencyAnalysis/ObjectWriter.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs index cd3ca61f27a5ec..58a6eb4131f86b 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs @@ -1153,7 +1153,10 @@ public static void EmitObject(string objectFilePath, IReadOnlyCollection Date: Thu, 9 Mar 2023 12:08:39 +0900 Subject: [PATCH 3/5] Apply suggestions from code review Co-authored-by: Jan Kotas --- .../Compiler/DependencyAnalysis/ObjectWriter.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs index 58a6eb4131f86b..a91fc47f55d0c0 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs @@ -1157,9 +1157,7 @@ public static void EmitObject(string objectFilePath, IReadOnlyCollection Date: Thu, 9 Mar 2023 12:14:07 +0900 Subject: [PATCH 4/5] Update ObjectWriter.cs --- .../Compiler/DependencyAnalysis/ObjectWriter.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs index a91fc47f55d0c0..963e093397012e 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs @@ -1157,7 +1157,9 @@ public static void EmitObject(string objectFilePath, IReadOnlyCollection gcMemoryInfo.TotalAvailableMemoryBytes / 2) + GC.Collect(GC.MaxGeneration, GCCollectionMode.Aggressive)); objectWriter.EmitDebugModuleInfo(); @@ -1167,6 +1169,7 @@ public static void EmitObject(string objectFilePath, IReadOnlyCollection Date: Thu, 9 Mar 2023 12:36:54 +0900 Subject: [PATCH 5/5] Update ObjectWriter.cs --- .../Compiler/DependencyAnalysis/ObjectWriter.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs index 963e093397012e..c5e164c8d914ac 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ObjectWriter.cs @@ -1156,10 +1156,14 @@ public static void EmitObject(string objectFilePath, IReadOnlyCollection gcMemoryInfo.TotalAvailableMemoryBytes / 2) - GC.Collect(GC.MaxGeneration, GCCollectionMode.Aggressive)); + { + if (logger.IsVerbose) + logger.LogMessage($"Freeing up memory"); + + GC.Collect(GC.MaxGeneration, GCCollectionMode.Aggressive); + } objectWriter.EmitDebugModuleInfo();