Skip to content

Commit

Permalink
8233712: Limit default tests jobs based on ulimit -u setting
Browse files Browse the repository at this point in the history
Reviewed-by: clanger
Backport-of: 753c58b
  • Loading branch information
gdams authored and RealCLanger committed Aug 4, 2022
1 parent 761e568 commit 08e51f5
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
18 changes: 18 additions & 0 deletions make/RunTests.gmk
Expand Up @@ -215,11 +215,29 @@ ifeq ($(TEST_JOBS), 0)
CORES_DIVIDER := 4
endif
endif
# For some big multi-core machines with low ulimit -u setting we hit the max
# threads/process limit. In such a setup the memory/cores-only-guided
# TEST_JOBS config is insufficient. From experience a concurrency setting of
# 14 works reasonably well for low ulimit values (<= 4096). Thus, use
# divider 4096/14. For high ulimit -u values this shouldn't make a difference.
ULIMIT_DIVIDER := (4096/14)
PROC_ULIMIT := -1
ifneq ($(OPENJDK_TARGET_OS), windows)
PROC_ULIMIT := $(shell $(ULIMIT) -u)
ifeq ($(PROC_ULIMIT), unlimited)
PROC_ULIMIT := -1
endif
endif
MEMORY_DIVIDER := 2048
TEST_JOBS := $(shell $(AWK) \
'BEGIN { \
c = $(NUM_CORES) / $(CORES_DIVIDER); \
m = $(MEMORY_SIZE) / $(MEMORY_DIVIDER); \
u = $(PROC_ULIMIT); \
if (u > -1) { \
u = u / $(ULIMIT_DIVIDER); \
if (u < c) c = u; \
} \
if (c > m) c = m; \
c = c * $(TEST_JOBS_FACTOR); \
c = c * $(TEST_JOBS_FACTOR_JDL); \
Expand Down
1 change: 1 addition & 0 deletions make/RunTestsPrebuiltSpec.gmk
Expand Up @@ -175,6 +175,7 @@ UNZIP := unzip
EXPR := expr
FILE := file
HG := hg
ULIMIT := ulimit

# On Solaris gnu versions of some tools are required.
ifeq ($(OPENJDK_BUILD_OS), solaris)
Expand Down
23 changes: 23 additions & 0 deletions make/autoconf/basics.m4
Expand Up @@ -541,6 +541,26 @@ AC_DEFUN([BASIC_REQUIRE_SPECIAL],
BASIC_CHECK_NONEMPTY($1)
])

###############################################################################
# Like BASIC_REQUIRE_PROGS but also allows for bash built-ins
# $1: variable to set
# $2: executable name (or list of names) to look for
# $3: [path]
AC_DEFUN([BASIC_REQUIRE_BUILTIN_PROGS],
[
BASIC_SETUP_TOOL($1, [AC_PATH_PROGS($1, $2, , $3)])
if test "x[$]$1" = x; then
AC_MSG_NOTICE([Required tool $2 not found in PATH, checking built-in])
if help $2 > /dev/null 2>&1; then
AC_MSG_NOTICE([Found $2 as shell built-in. Using it])
$1="$2"
else
AC_MSG_ERROR([Required tool $2 also not found as built-in.])
fi
fi
BASIC_CHECK_NONEMPTY($1)
])

###############################################################################
# Setup the most fundamental tools that relies on not much else to set up,
# but is used by much of the early bootstrap code.
Expand Down Expand Up @@ -1276,6 +1296,9 @@ AC_DEFUN_ONCE([BASIC_SETUP_COMPLEX_TOOLS],
elif test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
BASIC_REQUIRE_PROGS(ELFEDIT, elfedit)
fi
if ! test "x$OPENJDK_TARGET_OS" = "xwindows"; then
BASIC_REQUIRE_BUILTIN_PROGS(ULIMIT, ulimit)
fi
])

###############################################################################
Expand Down
1 change: 1 addition & 0 deletions make/autoconf/spec.gmk.in
Expand Up @@ -762,6 +762,7 @@ JIB_HOME:=@JIB_HOME@
XCODEBUILD=@XCODEBUILD@
DTRACE := @DTRACE@
FIXPATH:=@FIXPATH@
ULIMIT:=@ULIMIT@

TAR_TYPE:=@TAR_TYPE@
TAR_CREATE_EXTRA_PARAM:=@TAR_CREATE_EXTRA_PARAM@
Expand Down

1 comment on commit 08e51f5

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.