Skip to contentSkip to conversation

#define HZ 1024 -- negative effects?

DISCUSSION Dan Maas 4 participants 4 messages Apr 26, 2001 – Apr 28, 2001 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Dan Maas

author
#1 lore raw
Quoted 3 lines

Are there any negative effects of editing include/asm/param.h to change HZ from 100 to 1024? Or any other number? This has been suggested as a way to improve the responsiveness of the GUI on a Linux system.

I have also played around with HZ=1024 and wondered how it affects interactivity. I don't quite understand why it could help - one thing I've learned looking at kernel traces (LTT) is that interactive processes very, very rarely eat up their whole timeslice (even hogs like X). So more frequent timer interrupts shouldn't have much of an effect...

If you are burning CPU doing stuff like long compiles, then the increased HZ might make the system appear more responsive because the CPU hog gets pre-empted more often. However, you could get the same result just by running the task 'nice'ly...

The only other possibility I can think of is a scheduler anomaly. A thread arose on this list recently about strange scheduling behavior of processes using local IPC - even though one process had readable data pending, the kernel would still go idle until the next timer interrupt. If this is the case, then HZ=1024 would kick the system back into action more quickly...

Of course, the appearance of better interactivity could just be a placebo effect. Double-blind trials, anyone? =)

Regards,
Dan

#2 lore raw
Quoted 10 lines · Dan Maas
Quoted 3 lines

Are there any negative effects of editing include/asm/param.h to change HZ from 100 to 1024? Or any other number? This has been suggested as a way to improve the responsiveness of the GUI on a Linux system.

I have also played around with HZ=1024 and wondered how it affects interactivity. I don't quite understand why it could help - one thing I've learned looking at kernel traces (LTT) is that interactive processes very, very rarely eat up their whole timeslice (even hogs like X). So more frequent timer interrupts shouldn't have much of an effect...

Quoted 4 lines

If you are burning CPU doing stuff like long compiles, then the increased HZ might make the system appear more responsive because the CPU hog gets pre-empted more often. However, you could get the same result just by running the task 'nice'ly...

A tradeoff of having better system responsiveness by having the kernel to check more often if a running process should be preempted is that the CPU spends more time in Kernel Mode and less time in User Mode. And as a consequence, user programs run slower.

Regards,
Werner

#3 lore raw
In reply to Dan Maas
Quoted 5 lines · Dan Maas

The only other possibility I can think of is a scheduler anomaly. A thread arose on this list recently about strange scheduling behavior of processes using local IPC - even though one process had readable data pending, the kernel would still go idle until the next timer interrupt. If this is the case, then HZ=1024 would kick the system back into action more quickly...

Hmm. I've caught tasks looping here (experimental tree but..) with interrupts enabled, but schedule never being called despite having many runnable tasks.

-Mike

#4 lore raw
In reply to a message not in the archive
Quoted 3 lines · Dan Maas
Quoted 3 lines

Are there any negative effects of editing include/asm/param.h to change HZ from 100 to 1024? Or any other number? This has been suggested as a way to improve the responsiveness of the GUI on a Linux system.

[...]

Quoted 2 lines

Of course, the appearance of better interactivity could just be a placebo effect. Double-blind trials, anyone? =)

I tried HZ=1024 on my i386 kernel, to check two things. One was a timer routine. The performance of the timer routine depends heavily on the granularity of the nanosleep() or select() system call. Since those calls always block at least 1/HZ seconds, the timer precision indeed increased by a factor 10 when I changed the HZ value from 100 to 1024.

However, another thing I wanted to do was to generate profiling statistics for freesci. Profiling is done with 1/HZ granularity. Any subroutine in a program executed in less than 1/HZ cannot be profiled correctly (for example a routine that executes in 1 nanosecond and one that needs 1/HZ/2 seconds both show up as taking 1 sample).

Now, you would think that profiling would be a lot better with HZ=1024. However, the program didn't even run anymore! The reason is that some system calls are being interupted by SIGPROF every 1/HZ, and return something like ERESTARTSYS to the libraries. The libraries then try to restart the system call but a SIGPROF is bound to follow shortly, again interrupting the system call, and so on...

-------------------------------------------
Met vriendelijke groet / with kind regards,
Guus Sliepen <[email protected]>
-------------------------------------------
See also: http://tinc.nl.linux.org/
http://www.kernelbench.org/
-------------------------------------------