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

Pin the number of jobs in some Make targets #3640

Merged
merged 1 commit into from
Mar 31, 2022

Conversation

steakhal
Copy link
Contributor

@steakhal steakhal commented Mar 30, 2022

If someone runs make -j16 test_unit test_analyzer test_web_sqlite,
then the command would spuriously fail due to a filesystem race-condition.

The cp ldlogger build/bin would basically try to copy a not-yet-existing file,
causing a failure immediately, or later in the test pipeline, when it
exercises the logger. Causing an error similar to this:

make[1]: Leaving directory `codechecker/analyzer'
make: *** [test_analyzer] Error 2
make: *** Waiting for unfinished jobs....

Let's work around the issue by omitting the all target from the test* targets.
This way if it's already built, tests should just pass.

Makefile Outdated
Comment on lines 114 to 115
PIP_DEV_DEPS_CMD = $(MAKE) -C $(CC_ANALYZER) -j1 pip_dev_deps && \
$(MAKE) -C $(CC_WEB) -j1 pip_dev_deps && \
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need j1 here? The pip_dev_deps target in both cases will call a single pip install command:

pip_dev_deps:
pip3 install -r $(VENV_DEV_REQ_FILE)

codechecker/web/Makefile

Lines 50 to 51 in f11eb1a

pip_dev_deps:
pip3 install -r $(VENV_DEV_REQ_FILE)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I tried this, but let me try again.

@@ -66,7 +66,7 @@ test_functional_in_env: venv_dev
$(ACTIVATE_DEV_VENV) && $(FUNCTIONAL_TEST_CMD)

test_build_logger:
$(MAKE) -C tools/build-logger test
$(MAKE) -C tools/build-logger -j1 test
Copy link
Contributor

Choose a reason for hiding this comment

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

The problem with the test target is that it depends on the all target:

test: all pycodestyle pylint test_unit

And what all target will do is to build the package:

all: ldlogger ldlogger_32.so ldlogger_64.so pack32bit pack64bit

This is why your make command failes and gives you an error when you run it on multiple threads.

Can't we remove this dependency from the test target and assume you already built a package from ldlogger? That would solve the race condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Possible, but why should we assume it's already done?

Copy link
Contributor

Choose a reason for hiding this comment

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

If we do not assume that and if you run the for example the all target with multiple threads it is not guaranteed that the dependencies will be run in the correct order. For example the all target depends on the pack32bit target:

pack32bit: 32bit packbin

This target depends on two other targets: 32bit and packbin. The order is important here because the packbin target will assume that 32bit already run. If you run it with multiple threads this is not guaranteed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These should not depend on the order. If that's the case then packbin should explicitly depend on 32bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Anyway, I updated the patch to simply omit the all target from the test target deps.

@steakhal steakhal force-pushed the pin-num-jobs branch 2 times, most recently from 2a14888 to 2da8ddc Compare March 30, 2022 14:52
Copy link
Contributor

@csordasmarton csordasmarton left a comment

Choose a reason for hiding this comment

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

The test cases related to analyzer tools are failing. With your changes now you have to build a package from ldlogger before running the test cases:

- name: Run build-logger tests
working-directory: analyzer/tools/build-logger
run: |
pip install -r requirements_py/dev/requirements.txt
make test

I think that would solve the problem.

If someone runs `make -j16 test_unit test_analyzer test_web_sqlite`,
then the command would spuriously fail due to a filesystem
race-condition.

The `cp ldlogger build/bin` would basically try to copy a
not-yet-existing file,
causing a failure immediately, or later in the test pipeline, when it
exercises the logger. Causing an error similar to this:
```
make[1]: Leaving directory `codechecker/analyzer'
make: *** [test_analyzer] Error 2
make: *** Waiting for unfinished jobs....
```

Let's work around the issue by omitting the `all` target from the
`test*` targets. This way if it's already built, tests should just pass.
Copy link
Contributor

@csordasmarton csordasmarton left a comment

Choose a reason for hiding this comment

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

LGTM!

@csordasmarton csordasmarton merged commit 999ffda into Ericsson:master Mar 31, 2022
@steakhal steakhal deleted the pin-num-jobs branch March 31, 2022 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants