Discussion:
[gentoo-user] What exactly is kernel timer frequency?
(too old to reply)
Jure Varlec
2006-05-07 12:50:09 UTC
Permalink
What exactly does 'Timer frequency' (under 'Processor type and features') do?
Which timer does it control? I'm asking because it seems to have interesting
effects.

I used to have it set to 1KHz. Yesterday, I tried setting it to 100Hz just to
see what effects it would have. I didn't notice any impact on responsiveness.
There is a funny effect with superkaramba though. I noticed it with the
system monitor first, but I added a clock to see it better. I set the refresh
interval for the clock to 1 sec, and everytime it refreshes, it seems to
'skip a beat'. Hard to describe it. When it refreshes to show the current
number of seconds, it refreshes again a not-sot-tiny fraction of a second
later and shows the next second. Then, it fails to refresh for almost 2 sec,
then does it again.
It seems funny because 100Hz frequency is low enough for a human to observe
(or not, depending on what you're observing) but too high to cause such
behavior. That means I misunderstand what this setting does, so I'm turning
to you for an answer.
--
gentoo-***@gentoo.org mailing list
s***@gmail.com
2006-05-07 18:40:24 UTC
Permalink
Post by Jure Varlec
What exactly does 'Timer frequency' (under 'Processor type and features') do?
Which timer does it control? I'm asking because it seems to have interesting
effects.
I used to have it set to 1KHz. Yesterday, I tried setting it to 100Hz just to
see what effects it would have. I didn't notice any impact on responsiveness.
There is a funny effect with superkaramba though. I noticed it with the
system monitor first, but I added a clock to see it better. I set the refresh
interval for the clock to 1 sec, and everytime it refreshes, it seems to
'skip a beat'. Hard to describe it. When it refreshes to show the current
number of seconds, it refreshes again a not-sot-tiny fraction of a second
later and shows the next second. Then, it fails to refresh for almost 2 sec,
then does it again.
It seems funny because 100Hz frequency is low enough for a human to observe
(or not, depending on what you're observing) but too high to cause such
behavior. That means I misunderstand what this setting does, so I'm turning
to you for an answer.
I found a good "about the timer frequency" at
http://lwn.net/Articles/114991/

"Boot-time clock frequency selection
The timer interrupt is the kernel's way of keeping track of the passage of
time. Every so often, a programmable timer interrupts the kernel, which
responds by updating its internal time value, performing various
housekeeping tasks, and executing any delayed kernel work whose time has
come. In the 2.6 kernel, on the x86 architecture, by default, the timer
interrupt comes 1000 times per second; other architectures and
configurations can vary.

Playing with the timer tick frequency is almost as old as the kernel
itself. The frequency with which the hardware timer interrupts the
processor is well parameterized into a single compile-time variable (HZ);
running the system with a nonstandard clock frequency is simply a matter
of changing the definition of HZ (within reasonable bounds) and building a
new kernel.

There are legitimate reasons for playing with the timer frequency. A
faster clock can allow the system to perform more precise delays, and to
respond to events more quickly. Systems running at a higher clock
frequency should have lower latencies in many situations. There is an
overhead associated with the timer interrupt, however; a higher-frequency
interrupt will take more CPU time. So, for server loads (where latency is
less important), the overhead of a higher timer frequency is not worth it.
On laptops, the default 1KHz timer can also defeat the CPU's power
management features and significantly reduce battery life.

In other words, there is no single value for the timer frequency which
works for all users. Changing the frequency is still relatively hard,
however; some people are more comfortable with building new kernels than
others. Wouldn't it be nice if the frequency could be made into a
boot-time parameter, so that it could be changed from one boot to the next
without a kernel rebuild? "

I have noticed a big difference between 1000HZ and 100HZ on a system
running in VMware. The clock will often end up being much slower than the
real time clock just because VMware can't deal with the overhead (100HZ
being the fix).
--
gentoo-***@gentoo.org mailing list
Jure Varlec
2006-05-07 19:50:11 UTC
Permalink
Post by s***@gmail.com
I found a good "about the timer frequency" at
http://lwn.net/Articles/114991/
Thank you, it was an interesting read. I was googling around in the meanwhile,
and found
http://www.thinkwiki.org/wiki/Problem_with_high_pitch_noises and
http://linux.derkeiler.com/Mailing-Lists/Kernel/2005-11/1220.html

So now I mostly understand what this does. But the way the clock acts still
seems funny. Where could that "jump" come from? 100Hz seems too high for
that, unless I'm missing something.
Jure Varlec
2006-05-07 21:20:14 UTC
Permalink
Post by Jure Varlec
So now I mostly understand what this does. But the way the clock acts still
seems funny. Where could that "jump" come from? 100Hz seems too high for
that, unless I'm missing something.
I played with it some more. Only with superkaramba for now, as this is where
it's most apparent (haven't noticed this "jump/skip" anywhere else for now).
This "jump" seems to happen when I have multiple themes and/or sensors set to
the same update interval of 1 sec, i.e. when there are many processes
starting up at the same moment.
As the timer frequency relates to the process scheduler, I now believe that
with such a low frequency not all processes manage to complete their tasks
within the update interval. Therefore some of them update too late. But why
another update so soon after the last one? It makes me think two updates get
stacked and then both processed at the same time.

Pha. It's bloody obvious I haven't a clue about how this is all implemented.
While it's not an issue to be solved, it's interesting and I'd appreciate if
someone can explain this to me.

Loading...