Skip to content

Commit 318b495

Browse files
peter-mitsisnashif
authored andcommitted
tests: scheduler queue benchmarks
Implements a set of tests designed to show how the performance of the three scheduler queue implementations (DUMB, SCALABLE and MULTIQ) varies with respect to the number of threads in the ready queue. Signed-off-by: Peter Mitsis <[email protected]>
1 parent 2221ca8 commit 318b495

File tree

9 files changed

+515
-0
lines changed

9 files changed

+515
-0
lines changed

kernel/sched.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,3 +1599,13 @@ int z_sched_waitq_walk(_wait_q_t *wait_q,
15991599

16001600
return status;
16011601
}
1602+
1603+
/* This routine exists for benchmarking purposes. It is not used in
1604+
* general production code.
1605+
*/
1606+
void z_unready_thread(struct k_thread *thread)
1607+
{
1608+
K_SPINLOCK(&_sched_spinlock) {
1609+
unready_thread(thread);
1610+
}
1611+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.20.0)
4+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
5+
project(sched_queues)
6+
7+
FILE(GLOB app_sources src/*.c)
8+
target_sources(app PRIVATE ${app_sources})
9+
target_include_directories(app PRIVATE
10+
${ZEPHYR_BASE}/kernel/include
11+
${ZEPHYR_BASE}/arch/${ARCH}/include
12+
)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright (c) 2024 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
mainmenu "Scheduler Queue Benchmark"
5+
6+
source "Kconfig.zephyr"
7+
8+
config BENCHMARK_NUM_ITERATIONS
9+
int "Number of iterations to gather data"
10+
default 1000
11+
help
12+
This option specifies the number of times each test will be executed
13+
before calculating the average times for reporting.
14+
15+
config BENCHMARK_NUM_THREADS
16+
int "Number of threads"
17+
default 100
18+
help
19+
This option specifies the maximum number of threads that the test
20+
will add to the ready queue. Increasing this value will places greater
21+
stress on the ready queue and better highlight the performance
22+
differences as the number of threads in the ready queue changes.
23+
24+
config BENCHMARK_VERBOSE
25+
bool "Display detailed results"
26+
default y
27+
help
28+
This option displays the average time of all the iterations done for
29+
each thread in the tests. This generates large amounts of output. To
30+
analyze it, it is recommended to redirect the output to a file.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Scheduling Queue Measurements
2+
#############################
3+
4+
A Zephyr application developer may choose between three different scheduling
5+
algorithms--dumb, scalable and multiq. These different algorithms have
6+
different performance characteristics--characteristics that vary as the
7+
number of ready threads increases. This benchmark can be used to help
8+
determine which scheduling algorithm may best suit the developer's application.
9+
10+
This benchmark measures the ...
11+
* Time to add a threads of increasing priority to the ready queue
12+
* Time to add threads of decreasing priority to the ready queue
13+
* Time to remove highest priority thread from a wait queue
14+
* Time to remove lowest priority thread from a wait queue
15+
16+
By default, these tests show the minimum, maximum, and averages of the measured
17+
times. However, if the verbose option is enabled then the set of measured
18+
times will be displayed. The following will build this project with verbose
19+
support:
20+
21+
EXTRA_CONF_FILE="prj.verbose.conf" west build -p -b <board> <path to project>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Default base configuration file
2+
3+
CONFIG_TEST=y
4+
5+
# eliminate timer interrupts during the benchmark
6+
CONFIG_SYS_CLOCK_TICKS_PER_SEC=1
7+
8+
# We use irq_offload(), enable it
9+
CONFIG_IRQ_OFFLOAD=y
10+
11+
# Reduce memory/code footprint
12+
CONFIG_BT=n
13+
CONFIG_FORCE_NO_ASSERT=y
14+
15+
CONFIG_TEST_HW_STACK_PROTECTION=n
16+
# Disable HW Stack Protection (see #28664)
17+
CONFIG_HW_STACK_PROTECTION=n
18+
CONFIG_COVERAGE=n
19+
20+
# Disable system power management
21+
CONFIG_PM=n
22+
23+
CONFIG_TIMING_FUNCTIONS=y
24+
25+
CONFIG_HEAP_MEM_POOL_SIZE=2048
26+
CONFIG_APPLICATION_DEFINED_SYSCALL=y
27+
28+
# Disable time slicing
29+
CONFIG_TIMESLICING=n
30+
31+
CONFIG_SPEED_OPTIMIZATIONS=y
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Extra configuration file to enable verbose reporting
2+
# Use with EXTRA_CONF_FILE
3+
4+
CONFIG_BENCHMARK_VERBOSE=y

0 commit comments

Comments
 (0)