public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Runtime overhead of PREEMPT_DYNAMIC
@ 2023-10-20  9:14 Emanuele Rocca
  2023-10-20 12:42 ` Mike Galbraith
  0 siblings, 1 reply; 6+ messages in thread
From: Emanuele Rocca @ 2023-10-20  9:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Michal Hocko

Hi,

the Kconfig help for PREEMPT_DYNAMIC states the following:

  The runtime overhead is negligible with HAVE_STATIC_CALL_INLINE enabled
  but if runtime patching is not available for the specific architecture
  then the potential overhead should be considered.

I've tried evaluating the practical runtime overhead of PREEMPT_DYNAMIC
on my Ryzen 7 x86 workstation and it does actually seem quite
significant, for certain workloads.

I tried four different workloads: the first two are userspace-heavy (ie: the
CPU spends most of its time executing at the user level, as reported by sar
%user). There is *no* significant performance difference between a kernel with
PREEMPT_DYNAMIC=y and a kernel with PREEMPT_DYNAMIC=n for those:

1) compressing data with `xz -T 0` (less than 1% system)
   dd if=/dev/urandom of=/dev/stdout bs=1M count=1024 | xz --stdout -T 0 > /dev/null
2) building a kernel (10% system) 

The third and fourth benchmarks are kernel-heavy (ie: most of the CPU time is
at the system level, as reported by sar %system). The performance difference
between PREEMPT_DYNAMIC=y and PREEMPT_DYNAMIC=n is quite visible for those:

3) load testing nginx (35% system)
4) tbench (90% system)
   see https://www.samba.org/ftp/tridge/dbench/README

Details of the nginx benchmark:

- 'hey' (https://github.com/rakyll/hey) HTTP load generator version 0.1.4-2
- nginx 1.24.0 serving the default 'Welcome to nginx!' page
- logging to disk disabled with `access_log off` in nginx.conf
- hey -n 2000000 http://localhost/ | grep Requests

Results of the nginx benchmark:

- PREEMPT_DYNAMIC=n 102K rps
- PREEMPT_DYNAMIC=y 96K  rps
- 5% performance degradation with PREEMPT_DYNAMIC

Details of the tbench benchmark:

- tbench version 4.0 https://www.samba.org/ftp/tridge/dbench/
- Run /usr/bin/tbench_srv in a window
- Run /usr/bin/tbench `nproc` in another window

Results of the tbench benchmark:

- PREEMPT_DYNAMIC=n Throughput 3831.82 MB/sec
- PREEMPT_DYNAMIC=y Throughput 3006.54 MB/sec
- 20% performance degradation with PREEMPT_DYNAMIC

All the tests above were performed using Linux 6.5.6 on a AMD Ryzen 7 3700X
8-Core CPU.

Could someone please confirm whether the approach above seems sane and perhaps
try and reproduce the results?

Thanks,
  Emanuele

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-10-20 14:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-20  9:14 Runtime overhead of PREEMPT_DYNAMIC Emanuele Rocca
2023-10-20 12:42 ` Mike Galbraith
2023-10-20 13:40   ` Emanuele Rocca
2023-10-20 14:11     ` Mike Galbraith
2023-10-20 14:34       ` Mike Galbraith
2023-10-20 14:45         ` Emanuele Rocca

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox