Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: limit test-run jobs number to CPU count #7494

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion .test.mk
Expand Up @@ -17,6 +17,7 @@ MAX_PROCS ?= 2048
MAX_FILES ?= 4096

VARDIR ?= /tmp/t
TEST_RUN_JOBS ?= ${NPROC}
Copy link
Member

Choose a reason for hiding this comment

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

How it is supposed to work? It is not clear what is a ${NPROC} and where it is set.

TEST_RUN_PARAMS = --builddir ${PWD}/${BUILD_DIR}

COVERITY_DIR = cov-int
Expand Down Expand Up @@ -54,7 +55,8 @@ install-test-deps:

.PHONY: run-test
run-test: install-test-deps
cd test && ${TEST_RUN_ENV} ./test-run.py --force --vardir ${VARDIR} ${TEST_RUN_PARAMS} ${TEST_RUN_EXTRA_PARAMS}
cd test && ${TEST_RUN_ENV} ./test-run.py --force --jobs ${TEST_RUN_JOBS} --vardir ${VARDIR} \
${TEST_RUN_PARAMS} ${TEST_RUN_EXTRA_PARAMS}

##############################
# Linux #
Expand Down
15 changes: 15 additions & 0 deletions test/CMakeLists.txt
Expand Up @@ -48,29 +48,42 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/small
add_custom_target(symlink_libsmall_test_binaries ALL
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/small)

# Get the test-run jobs count from the env variable. If the variable is not
# defined, use the CPU count instead. If the ProcessorCount fails to determine
# the number of cores, it yields 0, which means for test-run 2 x CPU count.
set(TEST_RUN_JOBS $ENV{TEST_RUN_JOBS})
Copy link
Member

Choose a reason for hiding this comment

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

I believe it is better to have a single variable with number of jobs for everything: compilers, test-run.py, prove etc.
I can't imagine reasons to set a separate number of jobs for all three things.

if(NOT TEST_RUN_JOBS)
include(ProcessorCount)
ProcessorCount(TEST_RUN_JOBS)
endif()

Comment on lines 50 to +59
Copy link
Member

Choose a reason for hiding this comment

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

Can we reuse CMake module made for LuaJIT 1 (see discussion 2)?
I would reuse the same approach: CMake uses CMAKE_BUILD_PARALLEL_LEVEL 3 when it is set, or automatically set it to a maximum number of CPU's when it is empty.

Footnotes

  1. https://github.com/tarantool/luajit/blob/tarantool/cmake/SetBuildParallelLevel.cmake

  2. https://lists.tarantool.org/tarantool-patches/Ys6aKWKAEeY%2F4NYl@tarantool.org/T/#t

  3. https://cmake.org/cmake/help/latest/envvar/CMAKE_BUILD_PARALLEL_LEVEL.html

add_custom_target(test-unit
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/small
COMMAND ${PROJECT_SOURCE_DIR}/test/test-run.py
--jobs ${TEST_RUN_JOBS}
--builddir=${PROJECT_BINARY_DIR}
Copy link
Member

Choose a reason for hiding this comment

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

Should we use symbol = in --jobs as in --builddir option? The same below.

small/
unit/)

add_custom_target(test-unit-force
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/small
COMMAND ${PROJECT_SOURCE_DIR}/test/test-run.py
--jobs ${TEST_RUN_JOBS}
--builddir=${PROJECT_BINARY_DIR}
--force
small/
unit/)

add_custom_target(test-func
COMMAND ${PROJECT_SOURCE_DIR}/test/test-run.py
--jobs ${TEST_RUN_JOBS}
--builddir=${PROJECT_BINARY_DIR}
--exclude small/
--exclude unit/)

add_custom_target(test-func-force
COMMAND ${PROJECT_SOURCE_DIR}/test/test-run.py
--jobs ${TEST_RUN_JOBS}
--builddir=${PROJECT_BINARY_DIR}
--exclude small/
--exclude unit/
Expand All @@ -80,12 +93,14 @@ add_custom_target(test
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/small
LuaJIT-test
COMMAND ${PROJECT_SOURCE_DIR}/test/test-run.py
--jobs ${TEST_RUN_JOBS}
--builddir=${PROJECT_BINARY_DIR})

add_custom_target(test-force
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/small
LuaJIT-test
COMMAND ${PROJECT_SOURCE_DIR}/test/test-run.py
--jobs ${TEST_RUN_JOBS}
--builddir=${PROJECT_BINARY_DIR}
--force)

Expand Down