1 |
Hi folks. |
2 |
|
3 |
The forthcoming kernel will be introducing a rather visible (and |
4 |
potentially important) change. Firstly, it will provide an option to |
5 |
select the default timer frequency. Secondly, the default frequency |
6 |
will now be 250HZ. For the record, the value used to be 100HZ and was |
7 |
rather drastically changed to 1000HZ for 2.6. It will now be possible |
8 |
to choose a HZ value of either 100, 250 or 1000. |
9 |
|
10 |
The most interesting aspect of the timer is that it affects scheduling |
11 |
granularity. That is, the minimum possible time for which a given |
12 |
process is allowed to run before interruption. This is commonly known |
13 |
as a "jiffy" and can be calculated by dividing 1000 by the HZ value. |
14 |
So, the length of a jiffy in 2.6 at present is 1ms. In general, a |
15 |
longer jiffy results in more throughput but with more latency whereas |
16 |
a shorter jiffy results in less throughput (due to the overhead from |
17 |
frequent interruption) but with a reduction in latency. In my view, |
18 |
this is rather interesting in terms of the impact this can have on |
19 |
server performance. The help text for the new kernel configuration |
20 |
option explains further: |
21 |
|
22 |
- "Allows the configuration of the timer frequency. It is customary to |
23 |
have the timer interrupt run at 1000 HZ but 100 HZ may be more |
24 |
beneficial for servers and NUMA systems that do not need to have a |
25 |
fast response for user interaction and that may experience bus |
26 |
contention and cacheline bounces as a result of timer interrupts. Note |
27 |
that the timer interrupt occurs on each processor in an SMP |
28 |
environment leading to NR_CPUS * HZ number of timer interrupts per |
29 |
second." |
30 |
|
31 |
The specific help text for the 100HZ option is as follows: |
32 |
|
33 |
- "100 HZ is a typical choice for servers, SMP and NUMA systems with |
34 |
lots of processors that may show reduced performance if too many timer |
35 |
interrupts are occurring." |
36 |
|
37 |
For 250HZ: |
38 |
|
39 |
- "250 HZ is a good compromise choice allowing server performance |
40 |
while also showing good interactive responsiveness even on SMP and |
41 |
NUMA systems." |
42 |
|
43 |
For 1000HZ: |
44 |
|
45 |
- "1000 HZ is the preferred choice for desktop systems and other |
46 |
systems requiring fast interactive responses to events." |
47 |
|
48 |
Another interesting point that is not mentioned above is that reducing |
49 |
the timer frequency can significantly help to reduce time drift |
50 |
(particularly on "real" SMP systems where this effect may be even more |
51 |
pronounced). The reason that I am posting is twofold: |
52 |
|
53 |
* To notify everyone that this change is coming |
54 |
* To provide a means for anyone interested to test the ramifications |
55 |
of this newly acquired flexibility using a 2.6.12 kernel prior to the |
56 |
eventual release of 2.6.13. |
57 |
|
58 |
To that end I have grabbed the specific patch that adds the |
59 |
configuration option which can be found here: |
60 |
|
61 |
http://www.recruit2recruit.net/kerframil/2.6.12-i386-selectable-hz.patch |
62 |
|
63 |
This patch is taken directly from upstream (the option itself can be |
64 |
found at the bottom of the "Processor type and features" menu). |
65 |
Interestingly, the change has drawn attention to a few areas in the |
66 |
kernel where the methods used for timing (such as delay loops) are not |
67 |
ideal. So I have gone through all of the patches committed to the |
68 |
mainline tree since 2.6.12.3 and collected the ones that are relevant |
69 |
then aggregated them into one patch (the second one applies cleanly |
70 |
against a gentoo-sources tree): |
71 |
|
72 |
http://www.recruit2recruit.net/kerframil/2.6.12-timing-fixes-rollup.patch |
73 |
http://www.recruit2recruit.net/kerframil/2.6.12-gentoo-r7-timing-fixes-rollup.patch |
74 |
|
75 |
The individual patches are all very small and non-intrusive by nature. |
76 |
They are certainly not critical in order to be able to change the |
77 |
timer frequency but I recommend that they be used. For the curious, |
78 |
some notes on the contents of the patch can be found here here: |
79 |
http://www.recruit2recruit.net/kerframil/NOTES-2.6.12-timing-fixes-rollup |
80 |
|
81 |
What I would like is for anyone who is interested to put an alternate |
82 |
value (100 or 250) to the test (if they are in a position to be able |
83 |
to do so) and to determine whether there is any clear performance |
84 |
improvement with their workload. I switched my system (Compaq Proliant |
85 |
ML370) to 100HZ 2 days ago and can at least confirm that it is stable |
86 |
although I have not yet had the opportunity to perform any comparative |
87 |
benchmarks. If in doubt, then 250 might be a good value to try as, |
88 |
after all, that is going to be the default - at least for x86 ;) |
89 |
|
90 |
Finally, this topic has generated a nice little flame war over on the |
91 |
LKML (actually, it's quite an interesting thread if a little confusing |
92 |
at points): |
93 |
|
94 |
http://kerneltrap.org/node/5430 |
95 |
http://lkml.org/lkml/2005/7/8/259 |
96 |
|
97 |
Cheers, |
98 |
|
99 |
--Kerin Millar |
100 |
|
101 |
-- |
102 |
gentoo-server@g.o mailing list |