0

I've noticed that commonly if I ran:

while {
        start = now()
        pseudoFunction()
        end = now()
}

will run N x faster than (faster means duration of end - start)

while {
        start = now()
        pseudoFunction()
        end = now()
        sleep(100ms)
}

My assumption is that C-states, CPU boost, kernel scheduling and governor causes this. So without going to RT kernel, are there any means to tell CPU or Kernel that a latency sensitive routine is coming up? Please boost the clocks or give me thread attention?

I know that C-states and governor settings can be changed easily, but are there any other ways to improve latency or speed sensitive function's performance? Like does Intel has any API to artificially boost? Or are there any syscalls that could help prioritize? Would setting thread priority increase speed?

Thanks

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
kpeteL
  • 45
  • 5
  • 2
    Related: [Why does this delay-loop start to run faster after several iterations with no sleep?](https://stackoverflow.com/q/38299023) - newer Intel CPUs (starting with Skylake) support hardware P-state management which can ramp up to high clock speeds much more quickly (microseconds instead of milliseconds). One tunable setting for that is EPP, e.g. on Linux check via `grep . /sys/devices/system/cpu/cpufreq/policy[0-9]*/energy_performance_preference`, update via `sudo sh -c 'for i in /sys/devices/system/cpu/cpufreq/policy[0-9]*/energy_performance_preference;do echo performance > "$i";done'` – Peter Cordes Jun 27 '22 at 00:51
  • See also https://www.kernel.org/doc/html/latest/admin-guide/pm/intel_epb.html for `energy_perf_bias` (https://www.phoronix.com/scan.php?page=news_item&px=P-State-Power-EE-EPB-Knobs) and slides from a talk on Skylake power management (https://en.wikichip.org/w/images/8/83/Intel_Architecture%2C_Code_Name_Skylake_Deep_Dive-_A_New_Architecture_to_Manage_Power_Performance_and_Energy_Efficiency.pdf) from Intel's lead engineer who worked on that part of Skylake. (The slides are just about the CPU functionality, not how to configure it under any specific OS.) – Peter Cordes Jun 27 '22 at 00:54

0 Answers0