[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: rts: add -xr option to control two step allocator reserved space size
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Tue Mar 5 10:12:27 UTC 2024
Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
Commits:
1bc4e7ab by Cheng Shao at 2024-03-05T05:12:05-05:00
rts: add -xr option to control two step allocator reserved space size
This patch adds a -xr RTS option to control the size of virtual memory
address space reserved by the two step allocator on a 64-bit platform,
see added documentation for explanation. Closes #24498.
- - - - -
48325bf7 by Ben Gamari at 2024-03-05T05:12:06-05:00
filepath: Bump submodule to 1.5.2.0
- - - - -
2254cd78 by Ben Gamari at 2024-03-05T05:12:06-05:00
os-string: Bump submodule to 2.0.2
- - - - -
8 changed files:
- docs/users_guide/9.10.1-notes.rst
- docs/users_guide/runtime_control.rst
- libraries/filepath
- libraries/os-string
- rts/RtsFlags.c
- rts/include/rts/Flags.h
- rts/sm/MBlock.c
- testsuite/tests/rts/all.T
Changes:
=====================================
docs/users_guide/9.10.1-notes.rst
=====================================
@@ -232,6 +232,10 @@ Runtime system
- Add a :rts-flag:`--no-automatic-time-samples` flag which stops time profiling samples being automatically started on
startup. Time profiling can be controlled manually using functions in ``GHC.Profiling``.
+- Add a :rts-flag:`-xr ⟨size⟩` which controls the size of virtual
+ memory address space reserved by the two step allocator on a 64-bit
+ platform. See :ghc-ticket:`24498`.
+
``base`` library
~~~~~~~~~~~~~~~~
=====================================
docs/users_guide/runtime_control.rst
=====================================
@@ -368,6 +368,18 @@ Miscellaneous RTS options
thread can execute its exception handlers. The ``-xq`` controls the
size of this additional quota.
+.. rts-flag:: -xr ⟨size⟩
+
+ :default: 0.25T on aarch64, 1T otherwise
+
+ This option controls the size of virtual memory address space
+ reserved by the two step allocator on a 64-bit platform. It can be
+ useful in scenarios where even reserving a large address range
+ without committing can be expensive (e.g. WSL1), or when you
+ actually have enough physical memory and want to support a Haskell
+ heap larger than 1T. ``-xr`` is a no-op if GHC is configured with
+ ``--disable-large-address-space`` or if the platform is 32-bit.
+
.. _rts-options-gc:
RTS options to control the garbage collector
=====================================
libraries/filepath
=====================================
@@ -1 +1 @@
-Subproject commit b55465e3d174ccd63914e7146079435503204187
+Subproject commit 4dd36add328032f9cbf0eff2a3511ab4369b18eb
=====================================
libraries/os-string
=====================================
@@ -1 +1 @@
-Subproject commit fb2711ba1f43fd609de0e231e161025ee8ed3216
+Subproject commit 6c567f572e62437b8431b0f64b91393c40b677c8
=====================================
rts/RtsFlags.c
=====================================
@@ -186,6 +186,14 @@ void initRtsFlagsDefaults(void)
RtsFlags.GcFlags.ringBell = false;
RtsFlags.GcFlags.longGCSync = 0; /* detection turned off */
+#if defined(aarch64_HOST_ARCH)
+ // 1/4 TBytes, see 38c98e4f for rationale
+ RtsFlags.GcFlags.addressSpaceSize = (StgWord64)1 << 38;
+#else
+ // 1 TBytes
+ RtsFlags.GcFlags.addressSpaceSize = (StgWord64)1 << 40;
+#endif
+
RtsFlags.DebugFlags.scheduler = false;
RtsFlags.DebugFlags.interpreter = false;
RtsFlags.DebugFlags.weak = false;
@@ -552,6 +560,11 @@ usage_text[] = {
" -xq The allocation limit given to a thread after it receives",
" an AllocationLimitExceeded exception. (default: 100k)",
"",
+#if defined(USE_LARGE_ADDRESS_SPACE)
+" -xr The size of virtual memory address space reserved by the",
+" two step allocator (default: 0.25T on aarch64, 1T otherwise)",
+"",
+#endif
" -Mgrace=<n>",
" The amount of allocation after the program receives a",
" HeapOverflow exception before the exception is thrown again, if",
@@ -1820,6 +1833,12 @@ error = true;
/ BLOCK_SIZE;
break;
+ case 'r':
+ OPTION_UNSAFE;
+ RtsFlags.GcFlags.addressSpaceSize
+ = decodeSize(rts_argv[arg], 3, MBLOCK_SIZE, HS_INT_MAX);
+ break;
+
default:
OPTION_SAFE;
errorBelch("unknown RTS option: %s",rts_argv[arg]);
@@ -2118,7 +2137,9 @@ decodeSize(const char *flag, uint32_t offset, StgWord64 min, StgWord64 max)
m = atof(s);
c = s[strlen(s)-1];
- if (c == 'g' || c == 'G')
+ if (c == 't' || c == 'T')
+ m *= (StgWord64)1024*1024*1024*1024;
+ else if (c == 'g' || c == 'G')
m *= 1024*1024*1024;
else if (c == 'm' || c == 'M')
m *= 1024*1024;
@@ -2737,4 +2758,3 @@ doingErasProfiling( void )
|| RtsFlags.ProfFlags.eraSelector != 0);
}
#endif /* PROFILING */
-
=====================================
rts/include/rts/Flags.h
=====================================
@@ -89,6 +89,8 @@ typedef struct _GC_FLAGS {
bool numa; /* Use NUMA */
StgWord numaMask;
+
+ StgWord64 addressSpaceSize; /* large address space size in bytes */
} GC_FLAGS;
/* See Note [Synchronization of flags and base APIs] */
=====================================
rts/sm/MBlock.c
=====================================
@@ -659,20 +659,14 @@ initMBlocks(void)
#if defined(USE_LARGE_ADDRESS_SPACE)
{
- W_ size;
-#if defined(aarch64_HOST_ARCH)
- size = (W_)1 << 38; // 1/4 TByte
-#else
- size = (W_)1 << 40; // 1 TByte
-#endif
void *startAddress = NULL;
if (RtsFlags.GcFlags.heapBase) {
startAddress = (void*) RtsFlags.GcFlags.heapBase;
}
- void *addr = osReserveHeapMemory(startAddress, &size);
+ void *addr = osReserveHeapMemory(startAddress, &RtsFlags.GcFlags.addressSpaceSize);
mblock_address_space.begin = (W_)addr;
- mblock_address_space.end = (W_)addr + size;
+ mblock_address_space.end = (W_)addr + RtsFlags.GcFlags.addressSpaceSize;
mblock_high_watermark = (W_)addr;
}
#elif SIZEOF_VOID_P == 8
=====================================
testsuite/tests/rts/all.T
=====================================
@@ -3,7 +3,7 @@ test('testblockalloc',
compile_and_run, [''])
test('testmblockalloc',
- [c_src, only_ways(['normal','threaded1']), extra_run_opts('+RTS -I0'),
+ [c_src, only_ways(['normal','threaded1']), extra_run_opts('+RTS -I0 -xr0.125T'),
when(arch('wasm32'), skip)], # MBlocks can't be freed on wasm32, see Note [Megablock allocator on wasm] in rts
compile_and_run, [''])
# -I0 is important: the idle GC will run the memory leak detector,
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/996ec36554fd7b6fd5cbf74a96541e9f0cae10ca...2254cd78e793065c4eb8490321d6904bf7f1be2f
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/996ec36554fd7b6fd5cbf74a96541e9f0cae10ca...2254cd78e793065c4eb8490321d6904bf7f1be2f
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240305/1c577653/attachment-0001.html>
More information about the ghc-commits
mailing list