hermit-os / hermit-os/kernel

AArch64 scheduler performs worse when optimized

Open
#2,665 1 comment 0 reactions 2 assignees Claimed by @Gelbpunkt View on GitHub
Dominant language
Rust
Stars
1.5k
Forks
132
Avg merge
1d 14h
Merged PRs (30d)
39

Description

hermit-c's [pthreads.c](https://github.com/hermit-os/hermit-c/blob/51e041f706d1046a5c8a085841c7f2daf1869f2c/src/pthreads.c) test performs considerably worse when kernel optimizations are enabled. Suddenly, we have a huge number of rescheduling interrupts. This should be possible to reproduce in Rust.

```console
$ cargo xtask ci c --arch aarch64 --target pthreads --smp 4 qemu
...
../src/pthreads.c:44: assert(count_value == parallelism * ITERATIONS) successful
[ 36.035796][0][INFO interrupts] Number of interrupts
[ 36.039786][0][INFO interrupts] [0][Reschedule]: 5
[ 36.040927][0][INFO interrupts] [1][Reschedule]: 3
[ 36.041966][0][INFO interrupts] [2][Reschedule]: 3
[ 36.042901][0][INFO interrupts] [3][Reschedule]: 3
```

40e0c6ec1f19b8d157033411d1e2272ecd4936f1 (a year ago):

```console
$ cargo xtask ci c --arch aarch64 --buildtype release --target pthreads --smp 4 qemu
...
../src/pthreads.c:47: assert(count_value == parallelism * ITERATIONS) successful
[ 41.790805][0][INFO] Number of interrupts
[ 37.063989][0][INFO] [0][Reschedule]: 101420
[ 37.064255][0][INFO] [1][Reschedule]: 165798
[ 37.064444][0][INFO] [2][Reschedule]: 164730
[ 37.064600][0][INFO] [3][Reschedule]: 110663
```

5312fcaf6733e3353f63595498b66201ea591f36 (current `main`):

```console
$ cargo xtask ci c --arch aarch64 --buildtype release --target pthreads --smp 4 qemu
...
../src/pthreads.c:44: assert(count_value == parallelism * ITERATIONS) successful
[ 47.009291][0][INFO interrupts] Number of interrupts
[ 43.805069][0][INFO interrupts] [0][Reschedule]: 349560
[ 43.805359][0][INFO interrupts] [1][Reschedule]: 632670
[ 43.805540][0][INFO interrupts] [2][Reschedule]: 326619
[ 43.805706][0][INFO interrupts] [3][Reschedule]: 671266
```

A workaround for this worsening of performance in the last year is added in:
- https://github.com/hermit-os/hermit-c/pull/48

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.