summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Klebinger <klebinger.andreas@gmx.at>2020-04-06 13:35:23 +0200
committerAndreas Klebinger <klebinger.andreas@gmx.at>2020-06-23 15:57:51 +0200
commit3902d06522b4d591d40d68080821de6360f0325c (patch)
tree1140b7d8af5a6ab381095cd81d1da82c4280ab14
parentd4a0be758003f32b9d9d89cfd14b9839ac002f4d (diff)
downloadhaskell-wip/andreask/large_address_space.tar.gz
Enable large address space optimization on windows.wip/andreask/large_address_space
Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker.
-rw-r--r--configure.ac14
-rw-r--r--docs/users_guide/8.12.1-notes.rst11
-rw-r--r--rts/win32/OSMem.c2
3 files changed, 21 insertions, 6 deletions
diff --git a/configure.ac b/configure.ac
index 84880d8cb4..070f7ce56c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1219,11 +1219,15 @@ if test "$ac_cv_sizeof_void_p" -eq 8 ; then
if test "x$EnableLargeAddressSpace" = "xyes" ; then
if test "$ghc_host_os" = "darwin" ; then
use_large_address_space=yes
- elif test "$ghc_host_os" = "openbsd" ; then
- # as of OpenBSD 5.8 (2015), OpenBSD does not support mmap with MAP_NORESERVE.
- # The flag MAP_NORESERVE is supported for source compatibility reasons,
- # but is completely ignored by OS mmap
- use_large_address_space=no
+ elif test "$ghc_host_os" = "openbsd" ; then
+ # as of OpenBSD 5.8 (2015), OpenBSD does not support mmap with MAP_NORESERVE.
+ # The flag MAP_NORESERVE is supported for source compatibility reasons,
+ # but is completely ignored by OS mmap
+ use_large_address_space=no
+ elif test "$ghc_host_os" = "mingw32" ; then
+ # as of Windows 8.1/Server 2012 windows does no longer allocate the page
+ # tabe for reserved memory eagerly. So we are now free to use LAS there too.
+ use_large_address_space=yes
else
AC_CHECK_DECLS([MAP_NORESERVE, MADV_FREE, MADV_DONTNEED],[],[],
[
diff --git a/docs/users_guide/8.12.1-notes.rst b/docs/users_guide/8.12.1-notes.rst
index c729a8ec6c..bc2414489f 100644
--- a/docs/users_guide/8.12.1-notes.rst
+++ b/docs/users_guide/8.12.1-notes.rst
@@ -40,6 +40,11 @@ Highlights
GHC is now able to detect the case alt returning 3 as redundant.
- Some more performance improvements in edge cases.
+* Windows: Use the larg address space allocator.
+
+ This improves runtime but causes increased memory usage on Windows versions
+ older than Win 8.1/Server 2012.
+
Full details
------------
@@ -166,6 +171,12 @@ Runtime system
- Support for Windows Vista has been dropped. GHC-compiled programs now require
Windows 7 or later.
+- Windows now uses the large address space allocator by default.
+ In extreme cases we saw improvements by up to 3% decreased runtime.
+
+ The downside is that haskell apps run on older (Pre Win-8.1/Server 2012)
+ systems will have higher memory footprints.
+
Template Haskell
~~~~~~~~~~~~~~~~
diff --git a/rts/win32/OSMem.c b/rts/win32/OSMem.c
index 35fe72fd58..dd0f60ff0a 100644
--- a/rts/win32/OSMem.c
+++ b/rts/win32/OSMem.c
@@ -459,7 +459,7 @@ void *osReserveHeapMemory (void *startAddress, W_ *len)
void *start;
heap_base = VirtualAlloc(startAddress, *len + MBLOCK_SIZE,
- MEM_RESERVE, PAGE_READWRITE);
+ MEM_RESERVE | MEM_TOP_DOWN, PAGE_READWRITE);
if (heap_base == NULL) {
if (GetLastError() == ERROR_NOT_ENOUGH_MEMORY) {
errorBelch("out of memory");