I have a laptop with an Intel i7-1065G7 cpu. turbostat
reports
35 * 100.0 = 3500.0 MHz max turbo 8 active cores
35 * 100.0 = 3500.0 MHz max turbo 7 active cores
35 * 100.0 = 3500.0 MHz max turbo 6 active cores
35 * 100.0 = 3500.0 MHz max turbo 5 active cores
35 * 100.0 = 3500.0 MHz max turbo 4 active cores
35 * 100.0 = 3500.0 MHz max turbo 3 active cores
38 * 100.0 = 3800.0 MHz max turbo 2 active cores
39 * 100.0 = 3900.0 MHz max turbo 1 active cores
(these are 4 physical/8 virtual cores) When I throw a large single-thread load (calculating pi with mpfr
) at the cpu I observe that two cores (maybe one physical core?) run at exactly 3500 MHz while the others have a lower frequency. But they never reach the higher turbo boost frequencies.
If I disable some of the cpu cores (e.g. with echo 0 > /sys/devices/system/cpu/cpu[2-7]*/online
) the laptop does reach the corresponding higher turbo boost frequencies, resulting in increased performance (a task that took on average 18.5 seconds before now takes 16.8).
How can I get my new laptop to reach its maximal clock speed when not all cores are needed?
I'm using Ubuntu 20.04 with kernel 5.4.0 on an HP Envy x360 laptop.
What I expect:
On my old laptop with an i7-4712MQ turbostat
gives
30 * 100.0 = 3000.0 MHz max turbo 4 active cores
30 * 100.0 = 3000.0 MHz max turbo 3 active cores
32 * 100.0 = 3200.0 MHz max turbo 2 active cores
33 * 100.0 = 3300.0 MHz max turbo 1 active cores
(this is also a 4/8 core machine). On this machine a single-core load makes one core boost to almost 3.3 GHz, under a two-core load two clock at 3.2 GHz etc.
I haven't checked individual cpu frequencies on Windows, but the task manager sometimes displays frequencies above 3.7GHz.
Update: So the problem disappeared... I have no idea why. I did uninstall linux-cloud-tools
but I don't think this should be the reason.
You wrote...
If your program is single threaded it doesn't need to go to the maximum frequency on the other threads so it doesn't.
Your link is for the Intel® Core™ i7-1065G7 Processor.
The Intel document you linked says the max is 3900 MHz. Your data seem to show there is a core at 3900 MHz so I don't know why you think it did not hit the maximum. You posted this...
In general if the reading is not the maximum frequency it's because either it does so only intermittently so the measurement will only show that intermittently or else it doesn't need to be at the maximum frequency because there is some constraint such as IO. Don't worry about it. If you write a program that has no constraints, in other words, it is a compute constrained thread, I guarantee it will go to the max frequency.
An elapsed time of 18.5 s may not be meaningful because of random effects that you don't want to use to draw conclusions. Long running jobs of 200 seconds or more might give you more meaningful data.
I experienced something similar, on a similar setup (i7-9700K CPU, Ubuntu 18.04). And I think my machine usage may be similar: it's a desktop machine that I use for running some intensive (but single-thread) applications, while also possibly having a web browser and some messaging apps open. I found the suggestion in the comments under the original post to work - setting the CPU affinity for processes. I used
taskset
to do it [1].First test (no changes to affinity settings): All 8 cores 'idling' at ~10% utilisation. I start a single threaded, CPU intensive task. One core jumps to 100%, I see 3.6 GHz (the max without turbo) on all cores using
i7z
.Second test: Restrict all running processes to CPU cores 0 & 1, with:
for i in `sudo ps -aux | awk '{ print $2 }'`; do sudo taskset -a -p -c 0-1 $i; done
. Now those 2 cores sit at 30-40%, the rest at 0% (although some other cores may start to get activity as the OS starts processes). Then start the same single threaded, CPU intensive task. One core jumps to 100%, but now I see it reach the max turbo frequency of 4.9 GHz. Afterwards I set the affinity back to use all cores by replacing the0-1
range with0-7
, in my case.[1] http://manpages.ubuntu.com/manpages/focal/man1/taskset.1.html