zephyr/tests
Nicolas Pitre 099850e916 ring_buffer: the great simplification
This code is rather hairy. When I look at it I don't like the way it
stares back at me.

First, the rewind business looks fishy. It has to die.

And we don't have to rely on modulus either. Not even for non-power-of-2
buffers. Let's kill that distinction too and make all sizes always
"high performance".

The code is now entirely relying only on simple ALU operations (add,
sub and compare).

The key assumption: 32-bit values do wrap around after max range has
been reached. No saturation. All architectures supported by Zephyr
do that.

Some stats:

lib/os/ring_buffer.c: 62 insertions(+), 124 deletions(-)

ring_buffer.c.obj       before   after    diff
----------------------------------------------
frdm_k64f                 1224    1136     -88
m2gl025_miv               2485    2079    -406
mps2_an385                1228    1132     -96
mps2_an521                1228    1132     -96
native_posix              1546    1496     -50
native_posix_64           1598    1595      -3
nsim_hs_mpuv6             1252    1192     -60
nsim_hs_smp               1252    1192     -60
nsim_sem                  1252    1192     -60
qemu_arc_em               1324    1192    -132
qemu_arc_hs6x             1824    1620    -204
qemu_arc_hs               1252    1192     -60
qemu_cortex_a53_smp       2154    1888    -266
qemu_cortex_a53           2154    1888    -266
qemu_cortex_a9            1938    1792    -146

Before (qemu_cortex_a53):
START - test_ringbuffer_performance
1 byte put-get, avg cycles: 52
4 byte put-get, avg cycles: 47
1 byte put claim-finish, avg cycles: 39
5 byte put claim-finish, avg cycles: 41
5 byte get claim-finish, avg cycles: 52
 PASS - test_ringbuffer_performance in 0.8 seconds

After (qemu_cortex_a53):
START - test_ringbuffer_performance
1 byte put-get, avg cycles: 34
4 byte put-get, avg cycles: 41
1 byte put claim-finish, avg cycles: 27
5 byte put claim-finish, avg cycles: 29
5 byte get claim-finish, avg cycles: 29
 PASS - test_ringbuffer_performance in 0.4 seconds

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2022-02-24 14:49:00 -08:00
..
application_development/gen_inc_file kconfig: Rename the ZTEST stack size option to align with the rest 2022-02-22 08:23:05 -05:00
arch arch: arm: aarch32: Change CPU_CORTEX_R kconfig option 2022-02-23 08:14:15 -06:00
benchmarks arch: arm: aarch32: Change CPU_CORTEX_R kconfig option 2022-02-23 08:14:15 -06:00
bluetooth test: bluetooth: Update Bluetooth Mesh build test 2022-02-24 13:51:09 -08:00
boards
boot/uefi
cmake/config_dir
crypto kconfig: Rename the ZTEST stack size option to align with the rest 2022-02-22 08:23:05 -05:00
drivers drivers: can: unify CAN controller configuration in devicetree 2022-02-24 13:48:55 -08:00
kernel tests: kernel/common: fix inadequate failing to thread context 2022-02-24 08:38:38 -06:00
lib ring_buffer: the great simplification 2022-02-24 14:49:00 -08:00
misc tests: Run test_build only on platforms whose console has a driver 2022-02-21 22:17:27 -05:00
net net: lwm2m: Add proper resource-level discovery attribute handling 2022-02-22 10:12:27 -08:00
posix kconfig: Rename the TEST_EXTRA stack size option to align with the rest 2022-02-22 08:23:05 -05:00
subsys tests: logging: log_stack: Adjust log stack limits for SPARC 2022-02-24 08:51:26 -08:00
unit lib: os: crc: Rework the crc16() implementation 2022-02-04 12:33:22 -05:00
ztest arch: arm: aarch32: Change CPU_CORTEX_R kconfig option 2022-02-23 08:14:15 -06:00