Enabling CONFIG_TIMESLICING
and CONFIG_TICKLESS_KERNEL
at the same time makes thread switching much slower
#88353
Labels
area: Kernel
bug
The issue is a bug, or the PR is fixing a bug
priority: medium
Medium impact/importance bug
Describe the bug
When
CONFIG_TIMESLICING
(withCONFIG_TIMESLICE_SIZE
set to non-zero value) andCONFIG_TICKLESS_KERNEL
are enabled at the same time, the time required to switch threads is noticeably higher. In the outlier case on qemu_x86_64 with kvm enabled and single cpu the execution of the code was >100 times slower on the test platform after enabling tickless mode (without kvm and with default two cpus enabling tickless mode made it ~2 times slower). In the case of themimxrt685_evk
platform it was ~10 times slower, so the exact slowdown depends on the platform.The timeslice size doesn't seem to affect the results in a noticeable way.
To Reproduce
Run the following code with and without
CONFIG_TICKLESS_KERNEL
using the following config. This sample createsTHRD_C
threads,THRD_C
semaphores and passes control to the next threadREPEATS
times in a loop. At the end it prints the runtime.The snippet was built and run using the standard
west build -b board_name
andwest build -t run
/west flash
commands depending on platform type, apart fromqemu_x86_64
with a single CPU, which required launching it manually due to conflicts between-enable-kvm
and-icount
parameters:qemu-system-x86_64 -nographic -m 32 -enable-kvm -device loader,file=build/zephyr/zephyr-qemu-main.elf -kernel build/zephyr/zephyr-qemu-locore.elf
.Measured runtimes
Expected behavior
Enabling tickless mode shouldn't impact execution time noticeably.
Impact
In one app we've noticed up to multiple second delays after starting worker threads if tickless and timeslicing were enabled at the same time.
Environment:
The text was updated successfully, but these errors were encountered: