Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make/unit-tests make(1): limit memory usage in tests



details:   https://anonhg.NetBSD.org/src/rev/ad4ce65c0e9a
branches:  trunk
changeset: 946226:ad4ce65c0e9a
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Nov 21 17:44:40 2020 +0000

description:
make(1): limit memory usage in tests

There is a suspicious condition in SuffUpdateTarget code that looks wrong
on the first sight.  When removing it though, make allocates huge amounts
of memory.  To stop freezing the whole machine in this situation, limit
the total memory.

The limit of 200000 has been determined experimentally on NetBSD 8.0
x86_64.  With a limit of 100000, make wouldn't even start.  100 MB of
memory is really a lot for such a simple program that according to top(1)
only needs 8 MB.  But 200 MB is still better than 5 GB.

Since the Makefile is used on other platforms as well, via the bmake
distribution, and since every operating system has its own list of ulimit
options, make this configurable.

diffstat:

 usr.bin/make/unit-tests/Makefile |  8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diffs (29 lines):

diff -r cf7e0ffe8197 -r ad4ce65c0e9a usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Sat Nov 21 17:22:03 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Sat Nov 21 17:44:40 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.212 2020/11/21 10:32:42 rillig Exp $
+# $NetBSD: Makefile,v 1.213 2020/11/21 17:44:40 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -516,6 +516,11 @@
 
 MAKE_TEST_ENV?=        MALLOC_OPTIONS="JA"     # for jemalloc
 
+.if ${:!uname -s!} == "NetBSD"
+LIMIT_RESOURCES?=      ulimit -v 200000
+.endif
+LIMIT_RESOURCES?=      :
+
 # Each test is run in a sub-make, to keep the tests for interfering with
 # each other, and because they use different environment variables and
 # command line options.
@@ -523,6 +528,7 @@
 .mk.rawout:
        @${_MKMSG_TEST:Uecho '#      test '} ${.PREFIX}
        @set -eu; \
+       ${LIMIT_RESOURCES}; \
        cd ${.OBJDIR}; \
        env -i PATH="$$PATH" ${MAKE_TEST_ENV} ${ENV.${.PREFIX:T}} \
          ${TEST_MAKE} \



Home | Main Index | Thread Index | Old Index