A big set of kernel patches look like they will be submitted for the Linux 7.1 kernel cycle this spring to optimize the scheduler HRTICK timer and in turn allowing it to be enabled by default.
Thomas Gleixner and Peter Zijlstra have been tackling some optimizations to the HRTIMER subsystem for reducing the HRTICK timer overhead so it can be enabled by default. The high resolution tick “HRTICK” is part of the scheduler code for leveraging high precision hardware timers in contrast to the lower-frequency fixed-interval system tick. Opting for the HRTICK can yield better system responsiveness among other benefits.
Gleixner explained with a recent set of 48 patches:
“Peter recently posted a series tweaking the hrtimer subsystem to reduce the overhead of the scheduler hrtick timer so it can be enabled by default.
That turned out to be incomplete and led to a deeper investigation of the related bits and pieces.
The problem is that the hrtick deadline changes on every context switch and is also modified by wakeups and balancing. On a hackbench run this results in about 2500 clockevent reprogramming cycles per second, which is especially hurtful in a VM as accessing the clockevent device implies a VM-Exit.”
The end result from these patches are quite impressive:
“With all the above modifications in place enabling hrtick does not longer result in regressions compared to the hrtick disabled mode.
The reprogramming frequency of the clockevent device got down from ~2500/sec to ~100/sec for a hackbench run with a spurious hrtimer interrupt ratio of about 25%.
What’s interesting is the astonishing improvement of a hackbench run with the following command line parameters: ‘-l$LOOPS -p -s8’. That uses pipes with a message size of 8 bytes. On a 112 CPU SKL machine this results in:
NO HRTICK[_DL] HRTICK[_DL]
runtime: 0.840s 0.481s ~-42%With other message sizes up to 256, HRTICK still results in improvements, but not in that magnitude. Haven’t investigated the cause of that yet.”
Quite a nice improvement. Notably these patches are now queued in tip/tip.git’s sched/hrtick branch. With the patches now picked up by a TIP branch, they will likely be submitted during the Linux 7.1 merge window in April.
