Skip to content

zephyr-cp: run the tests in parallel - #11348

Open
lynt-smitka wants to merge 2 commits into
adafruit:mainfrom
MakerClassCZ:ci-zephyr-tests-xdist
Open

zephyr-cp: run the tests in parallel#11348
lynt-smitka wants to merge 2 commits into
adafruit:mainfrom
MakerClassCZ:ci-zephyr-tests-xdist

Conversation

@lynt-smitka

Copy link
Copy Markdown

make test runs the suite one test at a time. It is 17 of the zephyr-tests job's 34 to 44 minutes, and 84% of that is bsim, where every test runs a phy and one or two simulated devices.

pytest now runs with one worker per CPU. --dist loadfile keeps each file on one worker, which test_web_workflow.py needs for its fixed port 8090.

Measured locally on four cores, whole suite, 322 passed each time: 758 s with one worker, 350 s with two, 249 s with three, 224 s with four. -n auto asks psutil for physical cores, which inside a container is the host's count. If the bsim tests need more room on the runner, the count is one edit.

@tannewt tannewt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! One question about CPU count on actions VMs.

Comment thread ports/zephyr-cp/Makefile Outdated
test: $(TEST_BOARDS:%=test-build-%)
pytest cptools/tests
pytest tests/ -v
pytest tests/ -v -n 2 --dist loadfile

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Aren't most VMs now 4 CPU? Is there a way for use to pass the correct number in?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this should just be -v $(nproc) like the others

@lynt-smitka lynt-smitka Sep 11, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Originally, I had -n $$(nproc || sysctl -n hw.ncpu).

The run was https://github.com/adafruit/circuitpython/actions/runs/34614129245 - the suite finished in 7:38, but five bsim tests failed with Low level communication with phy failed. A bsim test runs a phy and one or two simulated devices, so with four workers a dozen CPU bound processes can share the four vCPUs (it's probably just 2 physical cores with HT). Two workers pass locally; the run on 2 is going now.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe split the bsim tests from the non-bsim?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The split has already been implemented in PR #11350. I still need to investigate this further to see if it's a dead end... It worked fine on my local machine 🙂

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think I've found the root cause of those build issues. This PR might be back in the game after PR #11353.

Not for merge as it stands: pytest-xdist is installed in the job rather
than in requirements-dev.txt, so that this change touches only a file
in IGNORE_BOARD and the run builds no boards.

The question is whether the bsim tests stay green when the only thing
they compete with is another bsim simulation. Earlier runs parallelised
the whole suite, where the asan native tests ran alongside: four
workers lost five tests, two workers lost one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants