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"); } (Expand)Author 2024-09-17tests: Adjust ‘elm’ importer test to expect inputs without labels....This is a followup af85c38b017be3d932d4665acd9ff4b5c56a9790. * tests/elm.scm ("(guix import elm)"): Expect new-style inputs. Change-Id: If3c6b17b5a5d17ad443c3ddb05f94dc2458ba182 Ludovic Courtès 2024-06-03import: utils: End package descriptions with period....* guix/import/utils.scm (beautify-description): Append period to last words which do not end with one. * tests/crate.scm: Append period to descriptions. * tests/elm.scm: Append period to descriptions. * tests/gem.scm: Append period to descriptions. * tests/hexpm.scm: Append period to descriptions. * tests/minetest.scm: Append period to descriptions. * tests/pypi.scm: Append period to descriptions. * tests/import-utils.scm ("beautify-description: transform fragment into sentence"): Likewise. Change-Id: I0b12c4d94cb26cf62fab5b7cbf7885e66ff6c10f Signed-off-by: Ludovic Courtès <ludo@gnu.org> Herman Rimm 2022-05-22import: Add Elm importer....* guix/import/elm.scm, guix/scripts/import/elm.scm: New files. * Makefile.am (MODULES): Add them. * guix/scripts/import.scm (importers): Add "elm". * doc/guix.texi (Invoking guix import): Document Elm importer. * doc/contributing.texi (Elm Packages): Mention it. * tests/elm.scm ("(guix import elm)"): New test group. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Philip McGrath 2022-05-22guix: Add elm-build-system....* gnu/packages/patches/elm-offline-package-registry.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/elm.scm (elm): Use it. * guix/build-system/elm.scm, guix/build/elm-build-system.scm, tests/elm.scm: New files. * Makefile.scm (MODULES, SCM_TESTS): Add them. * doc/guix.texi (Build Systems): Document 'elm-build-system'. * doc/contributing.texi (Elm Packages): New section. Document naming conventions and utilities. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Philip McGrath