Skip to content
Snippets Groups Projects
Commit 788675b0 authored by Alexander Kaznacheev's avatar Alexander Kaznacheev
Browse files

Add arbitraryHeapStart flag. It allows to allocate the memory block anywhere,...

Add arbitraryHeapStart flag. It allows to allocate the memory block anywhere, not only above the 8 GB.
Without it we can get an inifite loop in osReserveHeapMemory because ios sometimes doesn't allocate memory below the 8 GB
parent a56705f4
No related branches found
No related tags found
No related merge requests found
...@@ -144,6 +144,7 @@ data GCFlags = GCFlags ...@@ -144,6 +144,7 @@ data GCFlags = GCFlags
, minOldGenSize :: Word32 , minOldGenSize :: Word32
, heapSizeSuggestion :: Word32 , heapSizeSuggestion :: Word32
, heapSizeSuggestionAuto :: Bool , heapSizeSuggestionAuto :: Bool
, arbitraryHeapStart :: Bool
, oldGenFactor :: Double , oldGenFactor :: Double
, returnDecayFactor :: Double , returnDecayFactor :: Double
, pcFreeHeap :: Double , pcFreeHeap :: Double
...@@ -462,6 +463,8 @@ getGCFlags = do ...@@ -462,6 +463,8 @@ getGCFlags = do
<*> #{peek GC_FLAGS, heapSizeSuggestion} ptr <*> #{peek GC_FLAGS, heapSizeSuggestion} ptr
<*> (toBool <$> <*> (toBool <$>
(#{peek GC_FLAGS, heapSizeSuggestionAuto} ptr :: IO CBool)) (#{peek GC_FLAGS, heapSizeSuggestionAuto} ptr :: IO CBool))
<*> (toBool <$>
(#{peek GC_FLAGS, arbitraryHeapStart} ptr :: IO CBool))
<*> #{peek GC_FLAGS, oldGenFactor} ptr <*> #{peek GC_FLAGS, oldGenFactor} ptr
<*> #{peek GC_FLAGS, returnDecayFactor} ptr <*> #{peek GC_FLAGS, returnDecayFactor} ptr
<*> #{peek GC_FLAGS, pcFreeHeap} ptr <*> #{peek GC_FLAGS, pcFreeHeap} ptr
......
...@@ -162,6 +162,7 @@ void initRtsFlagsDefaults(void) ...@@ -162,6 +162,7 @@ void initRtsFlagsDefaults(void)
RtsFlags.GcFlags.heapLimitGrace = (1024 * 1024); RtsFlags.GcFlags.heapLimitGrace = (1024 * 1024);
RtsFlags.GcFlags.heapSizeSuggestion = 0; /* none */ RtsFlags.GcFlags.heapSizeSuggestion = 0; /* none */
RtsFlags.GcFlags.heapSizeSuggestionAuto = false; RtsFlags.GcFlags.heapSizeSuggestionAuto = false;
RtsFlags.GcFlags.arbitraryHeapStart = false;
RtsFlags.GcFlags.pcFreeHeap = 3; /* 3% */ RtsFlags.GcFlags.pcFreeHeap = 3; /* 3% */
RtsFlags.GcFlags.oldGenFactor = 2; RtsFlags.GcFlags.oldGenFactor = 2;
RtsFlags.GcFlags.returnDecayFactor = 4; RtsFlags.GcFlags.returnDecayFactor = 4;
...@@ -1055,6 +1056,11 @@ error = true; ...@@ -1055,6 +1056,11 @@ error = true;
OPTION_UNSAFE; OPTION_UNSAFE;
RtsFlags.HpcFlags.writeTixFile = false; RtsFlags.HpcFlags.writeTixFile = false;
} }
else if (strequal("arbitrary-heap-start",
&rts_argv[arg][2])) {
OPTION_UNSAFE;
RtsFlags.GcFlags.arbitraryHeapStart = true;
}
#if defined(THREADED_RTS) #if defined(THREADED_RTS)
#if defined(mingw32_HOST_OS) #if defined(mingw32_HOST_OS)
else if (!strncmp("io-manager-threads", else if (!strncmp("io-manager-threads",
......
...@@ -49,6 +49,7 @@ typedef struct _GC_FLAGS { ...@@ -49,6 +49,7 @@ typedef struct _GC_FLAGS {
uint32_t minOldGenSize; /* in *blocks* */ uint32_t minOldGenSize; /* in *blocks* */
uint32_t heapSizeSuggestion; /* in *blocks* */ uint32_t heapSizeSuggestion; /* in *blocks* */
bool heapSizeSuggestionAuto; bool heapSizeSuggestionAuto;
bool arbitraryHeapStart;
double oldGenFactor; double oldGenFactor;
double returnDecayFactor; double returnDecayFactor;
double pcFreeHeap; double pcFreeHeap;
......
...@@ -608,9 +608,11 @@ void *osReserveHeapMemory(void *startAddressPtr, W_ *len) ...@@ -608,9 +608,11 @@ void *osReserveHeapMemory(void *startAddressPtr, W_ *len)
// physical memory but a 511GB ulimit). See #14492. // physical memory but a 511GB ulimit). See #14492.
*len -= *len / 8; *len -= *len / 8;
// debugBelch("Limit hit, reduced len: %zu\n", *len); // debugBelch("Limit hit, reduced len: %zu\n", *len);
} else if ((W_)at >= minimumAddress) { } else if (RtsFlags.GcFlags.arbitraryHeapStart || (W_)at >= minimumAddress) {
// Success! We were given a block of memory starting above the 8 GB // Success! We were given a block of memory starting above the 8 GB
// mark, which is what we were looking for. // mark, which is what we were looking for.
// Or we allow to allocate the block anywhere by setting
// arbitraryHeapStart flag.
break; break;
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment