ghc runtime by default (otherwise depending on a "configure" option) does memory allocation on their own by first mmapping a 1 TB range of memory into the process and then parceling out chunks from it. If one of the chunks is not needed, the kernel needs to be informed - otherwise the system would quickly run out of available RAM. ghc does that via madvise(2). There are two options when doing this informing: MADV_FREE - Means "I don't need this range or the data in it any more". Kernel promises to fail later accesses to it. MADV_DONTNEED - Means "I don't need this range right now - and I don't need the data in it anymore". Kernel promises to make later accesses to it succeed (if necessary by providing a new page initialized with zeroes). MADV_FREE was introduced in Linux 4.5. glibc 2.25 and later always define MADV_FREE. Unpatched ghc 8.0.2 will use either MADV_FREE or MADV_DONTNEED, determined at ghc compile time. Which of them will actually succeed is determined by the Linux kernel at run time. This patch makes ghc try MADV_FREE. If it doesn't work, it falls back to MADV_DONTNEED. The end result is that ghc programs free their memory with Linux < 4.5 again. See https://git.haskell.org/ghc.git/commitdiff/6576bf83cdf4eac05eb88a24aa934a736c91e3da for more information. --- a/rts/posix/OSMem.c +++ b/rts/posix/OSMem.c @@ -541,11 +541,24 @@ void osDecommitMemory(void *at, W_ size) #ifdef MADV_FREE // Try MADV_FREE first, FreeBSD has both and MADV_DONTNEED - // just swaps memory out + // just swaps memory out. Linux >= 4.5 has both DONTNEED and FREE; either + // will work as they both allow the system to free anonymous pages. + // It is important that we try both methods as the kernel which we were + // built on may differ from the kernel we are now running on. r = madvise(at, size, MADV_FREE); -#else - r = madvise(at, size, MADV_DONTNEED); + if(r < 0) { + if (errno == EINVAL) { + // Perhaps the system doesn't support MADV_FREE; fall-through and + // try MADV_DONTNEED. + } else { + sysErrorBelch("unable to decommit memory"); + } + } else { + return; + } #endif + + r = madvise(at, size, MADV_DONTNEED); if(r < 0) sysErrorBelch("unable to decommit memory"); } 3ad95017c9b6d3162db148'>python.scm
AgeCommit message (Expand)Author
2023-07-20gnu: python: Support native build on the Hurd....Running "test_concurrent_futures" and "test_venv" freeze the Hurd. Tests "test_multiprocessing_forkserver" and "test_multiprocessing_spawn" run over 10mins. Debian simply skips all tests on the Hurd. * gnu/packages/python.scm (python-3.10)[arguments]: When building for the Hurd, add hanging and failing to #:make-flags's --exclude flag. Also, add 'disable-multi-processing' phase to avoid compileall.py hang during install. Janneke Nieuwenhuizen
2023-06-17gnu: Use target-hurd?, system-hurd? instead of hurd-target?, hurd-system?....* gnu/packages/hurd.scm (hurd-target?): Remove. (hurd-system?): Move to... * guix/utils.scm (system-hurd?): ...here. * gnu/packages/*: Update all users, removing (gnu packages hurd) include where now unused. Janneke Nieuwenhuizen
2023-04-14gnu: wrap-python3: Replace assoc-ref call with gexp variable....* gnu/packages/python.scm (wrap-python3) [arguments]: Replace assoc-ref call with gexp variable in builder. Maxim Cournoyer
2023-03-09gnu: python-wrapper: Refer to the target Python when cross-compiling....Previously, "guix build python-wrapper --target=aarch64-linux-gnu" would return a wrapper that symlinks the native programs (e.g., 'python3' for x86_64-linux) instead of the target programs. * gnu/packages/python.scm (wrap-python3)[arguments]: Use gexps. Use 'this-package-input' to refer to Python when cross-compiling. Ludovic Courtès
2023-03-02Merge remote-tracking branch 'savannah/master' into core-updates...Conflicts: gnu/local.mk gnu/packages/autotools.scm gnu/packages/cmake.scm gnu/packages/gnuzilla.scm gnu/packages/haskell.scm gnu/packages/pdf.scm gnu/packages/python-xyz.scm gnu/packages/samba.scm gnu/packages/tex.scm gnu/packages/tls.scm gnu/packages/wxwidgets.scm Christopher Baines
2023-02-25gnu: python: Remove input labels....* gnu/packages/python.scm (python-3.9)[native-inputs]: Remove labels. (python2-minimal)[inputs]: Likewise. (python-minimal)[inputs]: Likewise. Ludovic Courtès
2023-01-30Merge remote-tracking branch 'origin/master' into core-updates... Conflicts: doc/guix.texi gnu/local.mk gnu/packages/admin.scm gnu/packages/base.scm gnu/packages/chromium.scm gnu/packages/compression.scm gnu/packages/databases.scm gnu/packages/diffoscope.scm gnu/packages/freedesktop.scm gnu/packages/gnome.scm gnu/packages/gnupg.scm gnu/packages/guile.scm gnu/packages/inkscape.scm gnu/packages/llvm.scm gnu/packages/openldap.scm gnu/packages/pciutils.scm gnu/packages/ruby.scm gnu/packages/samba.scm gnu/packages/sqlite.scm gnu/packages/statistics.scm gnu/packages/syndication.scm gnu/packages/tex.scm gnu/packages/tls.scm gnu/packages/version-control.scm gnu/packages/xml.scm guix/build-system/copy.scm guix/scripts/home.scm Efraim Flashner