posts:nginx: Export HOME=/ to spawn-fcgi process for gitweb
[blog.git] / posts / CPU_frequency.mdwn
1 I usuall optimize my code for clean *code* and don't spend much time
2 worrying about optimizing for particular hardware, or really worrying
3 about hardware at all.  This is why I was surprised when I ran this on
4 our deparment computer lab:
5
6     wking@xphy1:~$ grep MHz /proc/cpuinfo
7     cpu MHz         : 2000.000
8     cpu MHz         : 3166.000
9
10 What!  Why is the CPU speed changing for a dual-core chip?  Some
11 searching around lead me to [cpufrequtils][] (Debian: `cpufrequtils`,
12 Gentoo: `sys-power/cpufrequtils`) and `cpufreq-info`:
13
14     wking@xphy1$ cpufreq-info 
15     cpufrequtils 006: cpufreq-info (C) Dominik Brodowski 2004-2009
16     Report errors and bugs to cpufreq@vger.kernel.org, please.
17     analyzing CPU 0:
18       driver: acpi-cpufreq
19       CPUs which run at the same hardware frequency: 0
20       CPUs which need to have their frequency coordinated by software: 0
21       maximum transition latency: 10.0 us.
22       hardware limits: 2.00 GHz - 3.17 GHz
23       available frequency steps: 3.17 GHz, 2.67 GHz, 2.33 GHz, 2.00 GHz
24       available cpufreq governors: conservative, ondemand, userspace,
25                       powersave, performance
26       current policy: frequency should be within 2.00 GHz and 3.17 GHz.
27                       The governor "ondemand" may decide which speed to use
28                       within this range.
29       current CPU frequency is 2.00 GHz (asserted by call to hardware).
30       cpufreq stats: 3.17 GHz:4.40%, 2.67 GHz:0.05%, 2.33 GHz:0.05%,
31                       2.00 GHz:95.49%  (3538)
32     analyzing CPU 1:
33       driver: acpi-cpufreq
34       CPUs which run at the same hardware frequency: 1
35       CPUs which need to have their frequency coordinated by software: 1
36       maximum transition latency: 10.0 us.
37       hardware limits: 2.00 GHz - 3.17 GHz
38       available frequency steps: 3.17 GHz, 2.67 GHz, 2.33 GHz, 2.00 GHz
39       available cpufreq governors: conservative, ondemand, userspace,
40                       powersave, performance
41       current policy: frequency should be within 2.00 GHz and 3.17 GHz.
42                       The governor "ondemand" may decide which speed to use
43                       within this range.
44       current CPU frequency is 2.00 GHz (asserted by call to hardware).
45       cpufreq stats: 3.17 GHz:4.03%, 2.67 GHz:0.77%, 2.33 GHz:0.03%,
46                       2.00 GHz:95.17%  (3743)
47
48 Now it makes sense ;).  Apparently the current (possibly throttled)
49 frequency is listed in `/proc/cpuinfo`, not the maximum frequency.
50
51 Also, the computer lab computers don't seem to be working very hard ;).
52
53 [cpufrequtils]: http://www.kernel.org/pub/linux/utils/kernel/cpufreq/cpufrequtils.html
54
55 [[!tag tags/linux]]
56 [[!tag tags/programming]]