View previous topic :: View next topic |
Author |
Message |
Paradox Uncreated n00b
Joined: 03 Oct 2012 Posts: 18 Location: Buskerud, Norway
|
Posted: Wed Oct 03, 2012 8:43 am Post subject: 0.2ms max latency target. |
|
|
Hi. I am downloading Gentoo DVD. I am trying to achieve max latency (max os-jitter) of 0.2ms. Ubuntu with a kernel configged for low-osjitter/low-latency comes quite close. Very few clicks in audiostreams at 0.3ms. So I thought maybe applying all the optimizations I could, and even system-wide PGO, might be a good thing.
So I thought a max optimized, with a target of game/audio/net/opengl/video (desktop) would be good, with only the components needed for that. Without unessecary security, daemons and modules etc. Only the raw performance.
Why?
Well, because once you have tried hardware with instant response, for instance, computers with a soundchip ~without latency, and arcades without jitter (virtua fighter etc), you want the same on your computer. Also performance is good, with low-osjitter. Low-latency everywhere is a good thing. And 0.2ms is ~instant response on audio, keypresses, mouseclicks etc, and graphics wise, contemporary games are in the 1fps range of improvement, with lower, and nobody cares about that. So 0.2ms is the target I want to try and achieve. That will also be very good for most desktop tasks. (videoprocessing etc.).
So whats the quickest way to do that, in Gentoo? _________________ Peace Be With You. |
|
Back to top |
|
|
PaulBredbury Watchman
Joined: 14 Jul 2005 Posts: 7310
|
|
Back to top |
|
|
aCOSwt Bodhisattva
Joined: 19 Oct 2007 Posts: 2537 Location: Hilbert space
|
Posted: Wed Oct 03, 2012 9:41 am Post subject: Re: 0.2ms max latency target. |
|
|
Paradox Uncreated wrote: | Hi. I am downloading Gentoo DVD. I am trying to achieve max latency (max os-jitter) of 0.2ms. Ubuntu with a kernel configged for low-osjitter/low-latency comes quite close. Very few clicks in audiostreams at 0.3ms. So I thought maybe applying all the optimizations I could, and even system-wide PGO, might be a good thing. |
0.2 ms... Gee ! On one core II duo system for which I think I have done the best I could do under a 3.4.9 kernel, I get 0.4ms average with rt_audio and rt_video.
My best advice for you is to opt for the sys-kernel/ck-sources package. (In Gentoo Portage currently 3.4.9 as recommended choice)
Thanks to the BFS patchset, you'll be granted with more or less crazy / insane values for CONFIG_HZ, values over 1000Hz (1500) and up to... well over (10.000)
It is the only possibility left open for me to halve my average latency if I want this... to the full expense of... everything else.
And its the only possibility I can think of for you if your target is 2/3 of what you currently get.
BTW, I assume you do not care a damn of power saving => you do not want to set CONFIG_NO_HZ.
EDIT : BTW, you'll then almost certainly want to play with /proc/sys/kernel/rr_interval and the sys-process/schedtool package but... that's a story we can discuss about in a second part. _________________
|
|
Back to top |
|
|
Paradox Uncreated n00b
Joined: 03 Oct 2012 Posts: 18 Location: Buskerud, Norway
|
Posted: Wed Oct 03, 2012 10:29 am Post subject: |
|
|
Yes, I already use schedtool. Very good posts! I will look at it. If hz 10 000 will give me 0.2ms latency max, I will do it. _________________ Peace Be With You. |
|
Back to top |
|
|
Paradox Uncreated n00b
Joined: 03 Oct 2012 Posts: 18 Location: Buskerud, Norway
|
Posted: Wed Oct 03, 2012 10:36 am Post subject: |
|
|
Btw, does anyknow know what filesystem gives the less jitter? For instance with ext2 latencies on normal threads are up to 5ms. But with ext4 it`s 1ms. _________________ Peace Be With You. |
|
Back to top |
|
|
Paradox Uncreated n00b
Joined: 03 Oct 2012 Posts: 18 Location: Buskerud, Norway
|
Posted: Wed Oct 03, 2012 10:53 am Post subject: |
|
|
I had a 3.5.4ck kernel lying around, and compiled it with 10000hz. It does indeed seem to reduce the clicks. But there still are some. I read that PGO can give a 7% speed increase. Lowlatency takes a lot of cpu, and might benefit from optimization. Also like the gentoo-studio page says, not adding any uneccesary daemons, would be nice.
Peace Be With You. _________________ Peace Be With You. |
|
Back to top |
|
|
aCOSwt Bodhisattva
Joined: 19 Oct 2007 Posts: 2537 Location: Hilbert space
|
Posted: Wed Oct 03, 2012 11:39 am Post subject: |
|
|
Paradox Uncreated wrote: | I had a 3.5.4ck kernel lying around, and compiled it with 10000hz. |
I had refrained from suggesting not to start testing from this end of the range... I had thought that... obvious...
For what is the best filesystem to use then... forget it. Choose whatever. Responsiveness has always been contradictory with IO throughput anyway.
So anything done in order to ease IO throughput compromises os-jitter.
So yes, opt for a non journaling basic fs. EXT2 being certainly the best on linux at this time.
And opt for the noop I/O scheduler.
(Of course, you want a SSD) _________________
|
|
Back to top |
|
|
Paradox Uncreated n00b
Joined: 03 Oct 2012 Posts: 18 Location: Buskerud, Norway
|
Posted: Wed Oct 03, 2012 12:12 pm Post subject: |
|
|
Ext2 is much worse with regards to os-jitter aCOSwt.
Also I compiled a kernel with 20hz timer, and it was no different from 10 000 hz in my apps. Latency the same. _________________ Peace Be With You. |
|
Back to top |
|
|
Paradox Uncreated n00b
Joined: 03 Oct 2012 Posts: 18 Location: Buskerud, Norway
|
Posted: Wed Oct 03, 2012 12:23 pm Post subject: |
|
|
Actually video jitter is much LESS with 20hz. Try my jitter-free video on http://paradoxuncreated.com/Blog/wordpress/?page_id=70
That was my experience with CFS granularity also. High value was good. So serveroriented values, seem good for low jitter.. Alteast in these cases. _________________ Peace Be With You. |
|
Back to top |
|
|
Paradox Uncreated n00b
Joined: 03 Oct 2012 Posts: 18 Location: Buskerud, Norway
|
Posted: Wed Oct 03, 2012 1:05 pm Post subject: |
|
|
I recompiled 3.6 with 250 hz. It seems good, and low jitter. Some more clicks than BFS with 0.3ms latency. So while some peak latencies are higher, overall jitter seems lower.
The 1000hz thing or higher, seems to be a myth. No doubt the kernel engineers set it to 250hz for a reason. _________________ Peace Be With You. |
|
Back to top |
|
|
Paradox Uncreated n00b
Joined: 03 Oct 2012 Posts: 18 Location: Buskerud, Norway
|
Posted: Wed Oct 03, 2012 1:13 pm Post subject: |
|
|
Well cfs shows slighty more jitter on videos. So they both have their strongpoints and weaknesses. I care more about openGL than videos though, so it will be CFS for me. Well I can try BFS on 250hz also. _________________ Peace Be With You. |
|
Back to top |
|
|
Paradox Uncreated n00b
Joined: 03 Oct 2012 Posts: 18 Location: Buskerud, Norway
|
Posted: Wed Oct 03, 2012 1:35 pm Post subject: |
|
|
Myeah, BFS on 250hz actually has more videojitter than BFS on 20hz And a tiny bit less than CFS. I can try CFS on 20hz too.
BFS has more jitter in doom3, than CFS, both at 250hz. And cfs at 250hz has less jitter than CFS at 1000hz in doom3. _________________ Peace Be With You. |
|
Back to top |
|
|
Paradox Uncreated n00b
Joined: 03 Oct 2012 Posts: 18 Location: Buskerud, Norway
|
Posted: Wed Oct 03, 2012 2:08 pm Post subject: |
|
|
Lol 20hz on CFS, seems to limit the FPS in doom3 severely, and speedup flash videos. Ok, one last compile at 100hz then. _________________ Peace Be With You. |
|
Back to top |
|
|
aCOSwt Bodhisattva
Joined: 19 Oct 2007 Posts: 2537 Location: Hilbert space
|
Posted: Wed Oct 03, 2012 2:10 pm Post subject: |
|
|
Hrmmm... no disrespect meant but, are you sure you are following a robust procedure based on robust tools when you make your observations ?
Just asking because in an hour and a half you seem reaching much more conclusions than I would in a whole day...
OK... I am getting old... _________________
|
|
Back to top |
|
|
Paradox Uncreated n00b
Joined: 03 Oct 2012 Posts: 18 Location: Buskerud, Norway
|
Posted: Wed Oct 03, 2012 2:31 pm Post subject: |
|
|
Theory is not always coherent with observation it seems. A lot of people do 1000hz on the desktop. I just tried 100hz, and it seems the best, atleast if you care about jitter first.
So atleast I have figured out the hz for me Ofcourse if this is what you want, or consider optimal, is up to what you care about. _________________ Peace Be With You. |
|
Back to top |
|
|
Paradox Uncreated n00b
Joined: 03 Oct 2012 Posts: 18 Location: Buskerud, Norway
|
Posted: Wed Oct 03, 2012 2:43 pm Post subject: |
|
|
Not only is 100hz the least jitter in native OpenGL, but on an old game like Q2 w/software renderer in wine, framerate is doubled. _________________ Peace Be With You. |
|
Back to top |
|
|
Paradox Uncreated n00b
Joined: 03 Oct 2012 Posts: 18 Location: Buskerud, Norway
|
Posted: Wed Oct 03, 2012 2:50 pm Post subject: |
|
|
Overall os-jitter less than 0.8ms for quite a while. (no clicks) If there are clicks they are rare. _________________ Peace Be With You. |
|
Back to top |
|
|
PaulBredbury Watchman
Joined: 14 Jul 2005 Posts: 7310
|
Posted: Wed Oct 03, 2012 3:12 pm Post subject: |
|
|
You'll probably do better with the real-time kernel.
Here's a little startup script I wrote, while testing the real-time kernel, to set up interrupt priorities for gaming:
Code: | #!/bin/bash
# Sorted view:
# ps -eLo rtprio,cls,pid,pri,nice,cmd | grep "FF" | sort -r
# For a non-RT kernel, use kernel option: threadirqs
# http://subversion.ffado.org/wiki/IrqPriorities
# http://alsa.opensrc.org/Rtirq
piwl=$(pgrep "irq/.*-iwlwifi")
[[ -n $piwl ]] && chrt -f -p 10 $piwl
peth=$(pgrep "irq/.*-eth0")
[[ -n $peth ]] && chrt -f -p 30 $peth
pmouse=$(pgrep "irq/19-uhci")
[[ -n $pmouse ]] && chrt -f -p 59 $pmouse
psnd=$(pgrep "irq/.*-snd_")
[[ -n $psnd ]] && chrt -f -p 80 $psnd
pkbd=$(pgrep "irq/.*-i8042")
# 2 of them
for p in $pkbd ; do
chrt -f -p 60 $p
done
prtc=$(pgrep "irq/.*-rtc0")
[[ -n $prtc ]] && chrt -f -p 90 $prtc
( while true ; do
# Does not have an IRQ until Xorg is running
pnvidia=$(pgrep "irq/.*-nvidia")
if [[ -n $pnvidia ]] ; then
chrt -f -p 70 $pnvidia
break
fi
sleep 20
done ) & |
I switched back to the normal kernel, because the real-time kernel seems to have issues (non-fatal kernel crashes) with VirtualBox.
If using BFS, I suggest to try using "nice" exclusively, instead of "schedtool".
Edit2: Tweaked priorities, increasing nvidia, and assigning 70 to all 3 of sound, mouse and keyboard.
Edit3: Tweaked priorities again - want sound higher than video.
Last edited by PaulBredbury on Thu Jan 03, 2013 12:34 pm; edited 3 times in total |
|
Back to top |
|
|
Paradox Uncreated n00b
Joined: 03 Oct 2012 Posts: 18 Location: Buskerud, Norway
|
Posted: Wed Oct 03, 2012 3:20 pm Post subject: |
|
|
Actually jitter levels are so low now with CFS, at 100hz, and a suitable granularity setting, that I don`t need realtime for gaming.
RT kernels usually are unstable on my machine also, unfortunately. Or I`d try it for (very) low-latency audio.
Threaded IRQs on mainline kernel doesn`t work either. _________________ Peace Be With You. |
|
Back to top |
|
|
Paradox Uncreated n00b
Joined: 03 Oct 2012 Posts: 18 Location: Buskerud, Norway
|
Posted: Mon Oct 08, 2012 12:07 am Post subject: |
|
|
Actually 90hz was even better. And killing ubuntu-daemons also was an improvement.
http://paradoxuncreated.com/Blog/wordpress/?p=3354
I am going to look into the audio gentoo install. But I haven`t got a whole HD for it yet, and it seems to explicitly state that. Or if someone knows if it can be installed to a partition?
I can`t do much more config wise, so PGO optimization + shaved runtime, would seem to be the next step.
Peace Be With You. _________________ Peace Be With You. |
|
Back to top |
|
|
Paradox Uncreated n00b
Joined: 03 Oct 2012 Posts: 18 Location: Buskerud, Norway
|
Posted: Thu Nov 08, 2012 10:09 am Post subject: Sum |
|
|
I have summed up my main points here:
http://paradoxuncreated.com/Blog/wordpress/?p=2268
--
Introduction, for thos new to "low-jitter":
John Carmack Quakecon 2012: "Doom 3 is still taxing on a modern PC".
He talks about only being able to run it at 30 fps on consoles. And simplified the engine for Rage, to be able to do 60 fps.
Doom 3 does 3 passes to OpenGL, and is very sensitive to jitter.
However on a LOW-JITTER linux kernel + config, you can run it gliding and silky smooth at 72 FPS, showing no taxation at all.
And it does not need to be the latest hardware. A core2duo + gtx280 will do.
For more info: http://paradoxuncreated.com/Blog/wordpress/?p=2268
A windows approximation can be found here: http://paradoxuncreated.com/Blog/wordpress/?p=1783
Windows will not run doom 3 aswell, and still drop frames, but it will help "microstutter".
Peace Be With You. _________________ Peace Be With You. |
|
Back to top |
|
|
Paradox Uncreated n00b
Joined: 03 Oct 2012 Posts: 18 Location: Buskerud, Norway
|
Posted: Thu Nov 08, 2012 10:14 am Post subject: |
|
|
PS, for script you can do Code: | schedtool -N -n 0 -p 0 `pgrep ""` | to change all priorities in one line. No for loops needed.
When I get my E5 box, I will have a look at threadirqs too. _________________ Peace Be With You. |
|
Back to top |
|
|
paulj Guru
Joined: 30 Sep 2004 Posts: 513 Location: Wales, UK
|
Posted: Fri Nov 09, 2012 10:28 am Post subject: |
|
|
How are you measuring the latency? Are you using latencyTop?
Do you consider the latency as the longest delay recorded when it reports?
Last edited by paulj on Fri Nov 09, 2012 10:52 am; edited 1 time in total |
|
Back to top |
|
|
Paradox Uncreated n00b
Joined: 03 Oct 2012 Posts: 18 Location: Buskerud, Norway
|
Posted: Fri Nov 09, 2012 10:52 am Post subject: |
|
|
Unfortunately there are some clicks at 0.3ms latency with my HDA soundchip, which is the lowest I can do in Renoise (96k smallest buffer). So 0.2ms latency target is not reached yet. But it is close. I am also getting an E5-workstation, with direct i/o, and I get get back to you on the latency figures on that if you want.
PS: with realtime threads, some professional firewire cards, already do 0.33ms latency stable. (Make sure to give rtgroup highest pri)
Peace Be With You. _________________ Peace Be With You. |
|
Back to top |
|
|
_______0 Guru
Joined: 15 Oct 2012 Posts: 521
|
Posted: Thu Jan 03, 2013 11:04 pm Post subject: |
|
|
PaulBredbury wrote: |
Code: | #!/bin/bash
# Sorted view:
# ps -eLo rtprio,cls,pid,pri,nice,cmd | grep "FF" | sort -r
# For a non-RT kernel, use kernel option: threadirqs
# http://subversion.ffado.org/wiki/IrqPriorities
# http://alsa.opensrc.org/Rtirq
piwl=$(pgrep "irq/.*-iwlwifi")
[[ -n $piwl ]] && chrt -f -p 10 $piwl
peth=$(pgrep "irq/.*-eth0")
[[ -n $peth ]] && chrt -f -p 30 $peth
pmouse=$(pgrep "irq/19-uhci")
[[ -n $pmouse ]] && chrt -f -p 59 $pmouse
psnd=$(pgrep "irq/.*-snd_")
[[ -n $psnd ]] && chrt -f -p 80 $psnd
pkbd=$(pgrep "irq/.*-i8042")
# 2 of them
for p in $pkbd ; do
chrt -f -p 60 $p
done
prtc=$(pgrep "irq/.*-rtc0")
[[ -n $prtc ]] && chrt -f -p 90 $prtc
( while true ; do
# Does not have an IRQ until Xorg is running
pnvidia=$(pgrep "irq/.*-nvidia")
if [[ -n $pnvidia ]] ; then
chrt -f -p 70 $pnvidia
break
fi
sleep 20
done ) & |
|
This is not a modern desktop, right??
Code: | pkbd=$(pgrep "irq/.*-i8042 |
looks like laptop. On a modern desktop is safe to disable ALL serial mouse/keyboard and just select evdev and boot with this kernel parameter:
Code: | i8042.noaux i8042.nokbd i8042.noloop i8042.nomux i8042.nopnp |
From /usr/src/linux/Documentation/kernel-parameters.txt:
Code: |
i8042.noaux [HW] Don't check for auxiliary (== mouse) port
i8042.nokbd [HW] Don't check/create keyboard port
i8042.noloop [HW] Disable the AUX Loopback command while probing
for the AUX port
i8042.nomux [HW] Don't check presence of an active multiplexing
controller
i8042.nopnp [HW] Don't use ACPIPnP / PnPBIOS to discover KBD/AUX
controllers
|
|
|
Back to top |
|
|
|