From 42cf430e3d109a3338251e3904b11f0a5076cb01 Mon Sep 17 00:00:00 2001 From: Manish Godse <61718172+mangod9@users.noreply.github.com> Date: Fri, 2 May 2025 12:51:09 -0700 Subject: [PATCH 1/7] try enabling regions on Mac again --- src/coreclr/gc/gcpriv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/gc/gcpriv.h b/src/coreclr/gc/gcpriv.h index e825b51d4d30c9..60732bf412419e 100644 --- a/src/coreclr/gc/gcpriv.h +++ b/src/coreclr/gc/gcpriv.h @@ -144,7 +144,7 @@ inline void FATAL_GC_ERROR() // For SunOS or illumos this is temporary, until we can add MAP_PRIVATE // to the mmap() calls in unix/gcenv.unix.cpp More details here: // https://github.com/dotnet/runtime/issues/104211 -#if defined (HOST_64BIT) && !defined (BUILD_AS_STANDALONE) && !defined(__APPLE__) && !defined(__sun) +#if defined (HOST_64BIT) && !defined (BUILD_AS_STANDALONE) && !defined(__sun) #define USE_REGIONS #endif //HOST_64BIT && BUILD_AS_STANDALONE && !__APPLE__ From 5fe5e6263fdad877071711eff1f8da0946ff7019 Mon Sep 17 00:00:00 2001 From: Manish Godse <61718172+mangod9@users.noreply.github.com> Date: Wed, 7 May 2025 13:50:10 -0700 Subject: [PATCH 2/7] dont enable for iOS and tvOS --- src/coreclr/gc/gcpriv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/gc/gcpriv.h b/src/coreclr/gc/gcpriv.h index 60732bf412419e..fe75f4ff0c0af0 100644 --- a/src/coreclr/gc/gcpriv.h +++ b/src/coreclr/gc/gcpriv.h @@ -144,7 +144,7 @@ inline void FATAL_GC_ERROR() // For SunOS or illumos this is temporary, until we can add MAP_PRIVATE // to the mmap() calls in unix/gcenv.unix.cpp More details here: // https://github.com/dotnet/runtime/issues/104211 -#if defined (HOST_64BIT) && !defined (BUILD_AS_STANDALONE) && !defined(__sun) +#if defined (HOST_64BIT) && !defined (BUILD_AS_STANDALONE) && !defined(__sun) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) #define USE_REGIONS #endif //HOST_64BIT && BUILD_AS_STANDALONE && !__APPLE__ From ff2904de062290dd537ba023476acf122481a493 Mon Sep 17 00:00:00 2001 From: Manish Godse <61718172+mangod9@users.noreply.github.com> Date: Wed, 7 May 2025 17:56:44 -0700 Subject: [PATCH 3/7] update binary size due to regions --- src/tests/nativeaot/SmokeTests/HardwareIntrinsics/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/nativeaot/SmokeTests/HardwareIntrinsics/Program.cs b/src/tests/nativeaot/SmokeTests/HardwareIntrinsics/Program.cs index 92e8f656f681af..a80ac4abd49930 100644 --- a/src/tests/nativeaot/SmokeTests/HardwareIntrinsics/Program.cs +++ b/src/tests/nativeaot/SmokeTests/HardwareIntrinsics/Program.cs @@ -22,7 +22,7 @@ static int Main() long lowerBound, upperBound; lowerBound = 1200 * 1024; // ~1.2 MB - upperBound = 1600 * 1024; // ~1.6 MB + upperBound = 1700 * 1024; // ~1.7 MB if (fileSize < lowerBound || fileSize > upperBound) { From c746c16a6aeff1c2038d0b656f1213c44511cc22 Mon Sep 17 00:00:00 2001 From: Manish Godse <61718172+mangod9@users.noreply.github.com> Date: Wed, 14 May 2025 21:58:20 -0700 Subject: [PATCH 4/7] update comment --- src/coreclr/gc/gcpriv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/gc/gcpriv.h b/src/coreclr/gc/gcpriv.h index fe75f4ff0c0af0..eddec5084f505f 100644 --- a/src/coreclr/gc/gcpriv.h +++ b/src/coreclr/gc/gcpriv.h @@ -140,7 +140,7 @@ inline void FATAL_GC_ERROR() // // This means any empty regions can be freely used for any generation. For // Server GC we will balance regions between heaps. -// For now disable regions for standalone GC and macOS builds +// For now disable regions for standalone GC and iOS and tvOS builds // For SunOS or illumos this is temporary, until we can add MAP_PRIVATE // to the mmap() calls in unix/gcenv.unix.cpp More details here: // https://github.com/dotnet/runtime/issues/104211 From 63a230d59b965e4da6097cbe5fad557a380b0310 Mon Sep 17 00:00:00 2001 From: Manish Godse <61718172+mangod9@users.noreply.github.com> Date: Tue, 20 May 2025 22:41:06 -0700 Subject: [PATCH 5/7] make regions_ranage 2x physical_mem for WKS --- src/coreclr/gc/gc.cpp | 5 +++++ src/coreclr/gc/gcpriv.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index 9ffb1de45c4488..b16751c6d6d205 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -49318,8 +49318,13 @@ HRESULT GCHeap::Initialize() } else { +#ifdef MULTIPLE_HEAPS // If no hard_limit is configured the reservation size is min of 1/2 GetVirtualMemoryLimit() or max of 256Gb or 2x physical limit. gc_heap::regions_range = max((size_t)256 * 1024 * 1024 * 1024, (size_t)(2 * gc_heap::total_physical_mem)); +#else // MUTLIPLE_HEAPS + // If no hard_limit is configured the reservation size is min of 1/2 GetVirtualMemoryLimit() or max of 256Gb or 2x physical limit. + gc_heap::regions_range = (size_t)(2 * gc_heap::total_physical_mem); +#endif // MUTLIPLE_HEAPS } size_t virtual_mem_limit = GCToOSInterface::GetVirtualMemoryLimit(); gc_heap::regions_range = min(gc_heap::regions_range, virtual_mem_limit/2); diff --git a/src/coreclr/gc/gcpriv.h b/src/coreclr/gc/gcpriv.h index eddec5084f505f..6806305ed1de6a 100644 --- a/src/coreclr/gc/gcpriv.h +++ b/src/coreclr/gc/gcpriv.h @@ -144,7 +144,7 @@ inline void FATAL_GC_ERROR() // For SunOS or illumos this is temporary, until we can add MAP_PRIVATE // to the mmap() calls in unix/gcenv.unix.cpp More details here: // https://github.com/dotnet/runtime/issues/104211 -#if defined (HOST_64BIT) && !defined (BUILD_AS_STANDALONE) && !defined(__sun) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) +#if defined (HOST_64BIT) && !defined (BUILD_AS_STANDALONE) && !defined(__sun) #define USE_REGIONS #endif //HOST_64BIT && BUILD_AS_STANDALONE && !__APPLE__ From a0ee7ecb4d269e9ee57f3ec580237e1a23e1193d Mon Sep 17 00:00:00 2001 From: Manish Godse <61718172+mangod9@users.noreply.github.com> Date: Thu, 22 May 2025 13:05:10 -0700 Subject: [PATCH 6/7] update reservationSize on iOS on my local testing looks like reservation of 1/4th of physical memory seems to succeed. --- src/coreclr/gc/gc.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index b16751c6d6d205..c9f78078b29b0b 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -49322,8 +49322,13 @@ HRESULT GCHeap::Initialize() // If no hard_limit is configured the reservation size is min of 1/2 GetVirtualMemoryLimit() or max of 256Gb or 2x physical limit. gc_heap::regions_range = max((size_t)256 * 1024 * 1024 * 1024, (size_t)(2 * gc_heap::total_physical_mem)); #else // MUTLIPLE_HEAPS +#if defined(TARGET_IOS) && defined(TARGET_TVOS) + // On iOS and tvOS only try to reserve 1/4 of physical memory + gc_heap::regions_range = (size_t)(gc_heap::total_physical_mem / 4); +#else // TARGET_IOS && TARGET_TVOS // If no hard_limit is configured the reservation size is min of 1/2 GetVirtualMemoryLimit() or max of 256Gb or 2x physical limit. gc_heap::regions_range = (size_t)(2 * gc_heap::total_physical_mem); +#endif // TARGET_IOS && TARGET_TVOS #endif // MUTLIPLE_HEAPS } size_t virtual_mem_limit = GCToOSInterface::GetVirtualMemoryLimit(); From 47ba0b70e3ade057744ba535b139e72f29218fd6 Mon Sep 17 00:00:00 2001 From: Manish Godse <61718172+mangod9@users.noreply.github.com> Date: Thu, 22 May 2025 14:16:22 -0700 Subject: [PATCH 7/7] fixing typo --- src/coreclr/gc/gc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index c9f78078b29b0b..cd859833330743 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -49322,7 +49322,7 @@ HRESULT GCHeap::Initialize() // If no hard_limit is configured the reservation size is min of 1/2 GetVirtualMemoryLimit() or max of 256Gb or 2x physical limit. gc_heap::regions_range = max((size_t)256 * 1024 * 1024 * 1024, (size_t)(2 * gc_heap::total_physical_mem)); #else // MUTLIPLE_HEAPS -#if defined(TARGET_IOS) && defined(TARGET_TVOS) +#if defined(TARGET_IOS) || defined(TARGET_TVOS) // On iOS and tvOS only try to reserve 1/4 of physical memory gc_heap::regions_range = (size_t)(gc_heap::total_physical_mem / 4); #else // TARGET_IOS && TARGET_TVOS