8214003: Limit default test jobs based on memory size

Reviewed-by: shade, tbell
This commit is contained in:
Erik Joelsson 2018-11-16 09:49:05 -08:00
parent bfc1488468
commit 1804d6ce65
2 changed files with 22 additions and 3 deletions

View File

@ -214,9 +214,12 @@ ifeq ($(TEST_JOBS), 0)
CORES_DIVIDER := 4 CORES_DIVIDER := 4
endif endif
endif endif
MEMORY_DIVIDER := 2048
TEST_JOBS := $(shell $(AWK) \ TEST_JOBS := $(shell $(AWK) \
'BEGIN { \ 'BEGIN { \
c = $(NUM_CORES) / $(CORES_DIVIDER); \ c = $(NUM_CORES) / $(CORES_DIVIDER); \
m = $(MEMORY_SIZE) / $(MEMORY_DIVIDER); \
if (c > m) c = m; \
c = c * $(TEST_JOBS_FACTOR); \ c = c * $(TEST_JOBS_FACTOR); \
c = c * $(TEST_JOBS_FACTOR_JDL); \ c = c * $(TEST_JOBS_FACTOR_JDL); \
c = c * $(TEST_JOBS_FACTOR_MACHINE); \ c = c * $(TEST_JOBS_FACTOR_MACHINE); \

View File

@ -95,12 +95,12 @@ endef
# $1: The output file name # $1: The output file name
# $2..$N: The lines to output to the file # $2..$N: The lines to output to the file
define CreateNewSpec define CreateNewSpec
$(if $(strip $(30)), \ $(if $(strip $(31)), \
$(error Internal makefile error: \ $(error Internal makefile error: \
Too many arguments to macro, please update CreateNewSpec in RunTestsPrebuilt.gmk) \ Too many arguments to macro, please update CreateNewSpec in RunTestsPrebuilt.gmk) \
) \ ) \
$(shell $(RM) $1) \ $(shell $(RM) $1) \
$(foreach i, $(call sequence, 2, 29), \ $(foreach i, $(call sequence, 2, 30), \
$(if $(strip $($i)), \ $(if $(strip $($i)), \
$(call AppendFile, $(strip $($i)), $1) \ $(call AppendFile, $(strip $($i)), $1) \
) \ ) \
@ -220,20 +220,35 @@ else
PATH_SEP:=: PATH_SEP:=:
endif endif
# Check number of cores # Check number of cores and memory in MB
ifeq ($(OPENJDK_TARGET_OS), linux) ifeq ($(OPENJDK_TARGET_OS), linux)
NUM_CORES := $(shell $(CAT) /proc/cpuinfo | $(GREP) -c processor) NUM_CORES := $(shell $(CAT) /proc/cpuinfo | $(GREP) -c processor)
MEMORY_SIZE := $(shell \
$(EXPR) `$(CAT) /proc/meminfo | $(GREP) MemTotal | $(AWK) '{print $$2}'` / 1024 \
)
else ifeq ($(OPENJDK_TARGET_OS), macosx) else ifeq ($(OPENJDK_TARGET_OS), macosx)
NUM_CORES := $(shell /usr/sbin/sysctl -n hw.ncpu) NUM_CORES := $(shell /usr/sbin/sysctl -n hw.ncpu)
MEMORY_SIZE := $(shell $(EXPR) `/usr/sbin/sysctl -n hw.memsize` / 1024 / 1024)
else ifeq ($(OPENJDK_TARGET_OS), solaris) else ifeq ($(OPENJDK_TARGET_OS), solaris)
NUM_CORES := $(shell LC_MESSAGES=C /usr/sbin/psrinfo -v | $(GREP) -c on-line) NUM_CORES := $(shell LC_MESSAGES=C /usr/sbin/psrinfo -v | $(GREP) -c on-line)
MEMORY_SIZE := $(shell \
/usr/sbin/prtconf 2> /dev/null | $(GREP) "^Memory [Ss]ize" | $(AWK) '{print $$3}' \
)
else ifeq ($(OPENJDK_TARGET_OS), windows) else ifeq ($(OPENJDK_TARGET_OS), windows)
NUM_CORES := $(NUMBER_OF_PROCESSORS) NUM_CORES := $(NUMBER_OF_PROCESSORS)
MEMORY_SIZE := $(shell \
$(EXPR) `wmic computersystem get totalphysicalmemory -value | $(GREP) = \
| $(CUT) -d "=" -f 2-` / 1024 / 1024 \
)
endif endif
ifeq ($(NUM_CORES), ) ifeq ($(NUM_CORES), )
$(warn Could not find number of CPUs, assuming 1) $(warn Could not find number of CPUs, assuming 1)
NUM_CORES := 1 NUM_CORES := 1
endif endif
ifeq ($(MEMORY_SIZE), )
$(warn Could not find memory size, assuming 1024 MB)
MEMORY_SIZE := 1024
endif
# Setup LD for AOT support # Setup LD for AOT support
ifneq ($(DEVKIT_HOME), ) ifneq ($(DEVKIT_HOME), )
@ -298,6 +313,7 @@ $(call CreateNewSpec, $(NEW_SPEC), \
OPENJDK_TARGET_CPU_BITS := $(OPENJDK_TARGET_CPU_BITS), \ OPENJDK_TARGET_CPU_BITS := $(OPENJDK_TARGET_CPU_BITS), \
OPENJDK_TARGET_CPU_ENDIAN := $(OPENJDK_TARGET_CPU_ENDIAN), \ OPENJDK_TARGET_CPU_ENDIAN := $(OPENJDK_TARGET_CPU_ENDIAN), \
NUM_CORES := $(NUM_CORES), \ NUM_CORES := $(NUM_CORES), \
MEMORY_SIZE := $(MEMORY_SIZE), \
LD := $(LD), \ LD := $(LD), \
LIBRARY_PREFIX := $(LIBRARY_PREFIX), \ LIBRARY_PREFIX := $(LIBRARY_PREFIX), \
SHARED_LIBRARY_SUFFIX := $(SHARED_LIBRARY_SUFFIX), \ SHARED_LIBRARY_SUFFIX := $(SHARED_LIBRARY_SUFFIX), \