# Increase Interrupts per second RTC

## silent_Walker

So recently I found my old '05 grade Pentium 4 HP computer still churning out 3.3 Ghz on its single core processor.  Trying Puppy, Peppermint and even Chrunchbang I was unsatisfied with the performance of not only flash but also application execution. 

Being a "Googler" I wandered around Homebrew computer websites, because many wrote their own operating systems.  And I found an OS written in Assembly called BareMetal OS, which has no GUI or TCP/IP stack as of yet.  Making it unusable unless you code that part in.  Which I don't mind doing.  However wandering around in their Google Groups I found that their OS uses the RTC to send out the INT per second.  Here is a excerpt from poster Ian Seyler on what it supports.

BareMetal uses the computers built-in RealTime Clock for timing. The RTC is configured to trigger an interrupt 8 times per seconds (8Hz). Not ideal for your use but it can be reconfigured. The RTC supports the following rates:

  RS    Int/sec         Period

3210      -              -

0000   none            none

0001    256            3.90625 ms

0010    128            7.8125  ms

0011   8192            122.070 Micros

0100   4096            244.141 Micros

0101   2048            488.281 Micros

0110   1024            976.562 Micros

0111    512            1.93125 ms

1000    256            3.90625 ms

1001    128            7.8125  ms

1010     64            15.625  ms

1011     32            31.25   ms

1100     16            62.50   ms

1101      8            125.0   ms

1110      4            250.0   ms

1111      2            500.0   ms

1024 for 976.562 period interested me, with the CPU being 3.3 Ghz I am pretty sure I will see noise but not as much as the stock configuration.  So my question is : Is it possible to configure the Linux Kernel to support those numbers.  And if so how?  I would imagine configuring the RTC file, but is this true?

----------

## eccerr0r

I'm still not certain why you think rtc interrupts is the reason why your machine is running slow.  Increasing interrupts/second means there's more work for the computer, which means things run slower...

It seems like you want 1ms interrupts, but isn't that the same thing as the 1000Hz clock timer (Hz) setting?

Really you should just try running Gentoo and optimizing to your hardware instead of generic support, which is what some Linux distributions do...  Make sure your video driver is optimized, a lot of things that look slow end up being using generic video drivers.

----------

## John R. Graham

Not all of those numbers, but some of them. The basic tick rate is programmable in the kernel configuration to 100Hz, 250Hz, 300Hz, and 1KHz. See the CONFIG_HZ symbols in the .config file or, in menuconfig at Processor type and features / Timer frequency.

- John

----------

## PaulBredbury

One can hack the kernel to change the HZ. E.g. as in pf-kernel.

I've found 432hz to be good with dual-core, and am currently checking to see if 600hz is better.

----------

## silent_Walker

 *John R. Graham wrote:*   

> Not all of those numbers, but some of them. The basic tick rate is programmable in the kernel configuration to 100Hz, 250Hz, 300Hz, and 1KHz. See the CONFIG_HZ symbols in the .config file or, in menuconfig at Processor type and features / Timer frequency.
> 
> - John

 

I currently had all of my kernels at 1KHz.  Also, I thought Micro stood for Microsecond, that is why I created this post.  Sending out Interrupts in the microsecond range seems pretty more impressive then the millisecond range.

----------

## silent_Walker

 *PaulBredbury wrote:*   

> One can hack the kernel to change the HZ. E.g. as in pf-kernel.
> 
> I've found 432hz to be good with dual-core, and am currently checking to see if 600hz is better.

 

Thanks man I will defiantly look at that  :Very Happy: 

----------

## silent_Walker

 *eccerr0r wrote:*   

> I'm still not certain why you think rtc interrupts is the reason why your machine is running slow.  Increasing interrupts/second means there's more work for the computer, which means things run slower...
> 
> It seems like you want 1ms interrupts, but isn't that the same thing as the 1000Hz clock timer (Hz) setting?
> 
> Really you should just try running Gentoo and optimizing to your hardware instead of generic support, which is what some Linux distributions do...  Make sure your video driver is optimized, a lot of things that look slow end up being using generic video drivers.

 

From what I seen, a single core processor with at least a 1.5 Ghz frequency should not go above about 1000 Hz.  This however has double that so more or less it should be able  to cope with the noise.  

1000Hz is 1ms, though I wanted something smaller then 1ms.  Last time I built a Zen kernel the value went as high as 10000Hz, which worked for Linux Mint 11.

----------

## Ant P.

What broken, HZ-value dependent software are you running?

----------

## eccerr0r

^^ Yes, I am very curious as well.

The HZ setting should only be valuable to real-time applications or drivers, and once again the lowest number possible is the ideal value to this option as interrupt processing time is a waste of CPU cycles.  Having the interrupt rate higher will not make any perception of speed other than making timing more accurate between each event....

----------

## NeddySeagoon

eccerr0r,

You confuse accuracy and precision.

If the RTC timebase has a poor quality crystal and PCs do, it may be 0.1% slow or worse.  This is constant no matter what the IRQ rate. This determines the accuracy.

When the IRQ rate is increased, the precision gets better.  At 100Hz, the precision is 10ms at best, ay 1000Hz, its 1ms at best.

----------

## silent_Walker

Almost a Week rummaging through the RTC portion of the kernel and still have no idea what I am doing...lol

Think I might just start changing something that looks like it deals with interrupts  :Very Happy: 

----------

## PaulBredbury

Here's a kernel patch to add 432 and 600 as hz options.

----------

## silent_Walker

 *PaulBredbury wrote:*   

> Here's a kernel patch to add 432 and 600 as hz options.

 

Appreciate that bro, never did know how to write a patch :3

----------

## silent_Walker

I just thought of something, if the Kernel does Hz * by the # of cpu cores you have, realistically the number of cpus could be manually altered further adjusting the interrupts, right?

----------

## silent_Walker

 *PaulBredbury wrote:*   

> Here's a kernel patch to add 432 and 600 as hz options.

 

Tweaked the patch to 2000 Hz, it is compiling now.  Maybe in an hour or so well see what happens.

----------

## John R. Graham

Yep, we will: your system will be even slower.   :Wink:  More interrupt overhead means less cycles available for work. You're way beyond the point of diminishing returns in latency reduction.

- John

----------

## silent_Walker

Kernel just got done compiling.  Nothing is broken.... or nothing important broke during the process.  It's getting pretty late so tomorrow or maybe this weekend I will do some benching and see what happens.

----------

