Skip to content

zephyr-cp tests: read serial output in chunks instead of one byte at a time - #11353

Open
lynt-smitka wants to merge 2 commits into
adafruit:mainfrom
MakerClassCZ:zephyr-bsim-reader
Open

zephyr-cp tests: read serial output in chunks instead of one byte at a time#11353
lynt-smitka wants to merge 2 commits into
adafruit:mainfrom
MakerClassCZ:zephyr-bsim-reader

Conversation

@lynt-smitka

Copy link
Copy Markdown

SerialSaver's reader thread read one byte at a time and appended it to an attribute, so each byte copied the whole string: 993 KB took 9.4 s, 1.99 MB took 35.6 s. Each bsim test pipes about 1.1 MB of phy output through it, against a wall-clock budget.

It now reads whatever is already buffered. The bsim suite (118 tests) goes from 554.7 s to 109.6 s idle. The two files that fail most on CI go from 144 s to 26 s, and under load from 340 s with 2 of 3 runs failing to 57 s, all green. This may also be behind the intermittent Low level communication with phy failed errors.

The second commit drops duration(5) from one bsim test, the only one below the default 10 s. It failed at 5 s under load and passed at 10 s.

SerialSaver's reader thread read one byte per iteration and appended it to
self.all_output. That store goes through STORE_ATTR, so CPython's in-place
unicode concatenation does not apply and every byte copies the whole string.

The bsim tests run the BabbleSim phy at -v=9 through the same reader, which is
about 1.1 MB per test. Measured here, 993 KB of that costs 9.4 s in the reader
against a test budget of 10 to 30 s of wall clock, and the phy stalls whenever
the reader falls more than one pipe buffer behind.

Read what is already buffered instead. The two bsim test files go from 144 s to
26 s on an idle host, and from 340 s with failures to 57 s green under CPU
oversubscription.
It was the only bsim test below the default 10 s, and it is the first one to
miss its deadline when the host is busy: with 32 spinning processes on a 4 core
machine it failed both runs at 5 s and passed all three at 10 s.

The timeout is only an upper bound, wait_until_done() returns as soon as the
device exits, so the larger budget costs nothing when the test passes. The full
bsim suite runs in 106 s either way.
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.

1 participant