Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Real time gaming: A complete disaster
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gamers & Players
View previous topic :: View next topic  
Author Message
V10lator
Apprentice
Apprentice


Joined: 11 Jul 2004
Posts: 166

PostPosted: Mon Jul 29, 2013 3:45 pm    Post subject: Real time gaming: A complete disaster Reply with quote

I decided to experiment a bit with real time scheduling and gaming. To do that I used a real time kernel and added the following to my autostart (executed as root):
Code:
chrt -a -p -r 9 `pidof X`

Which seems to work:
Code:
$ schedtool `pidof X`
PID  2285: PRIO  9, POLICY R: SCHED_RR      , NICE   0, AFFINITY 0x7

Also I enabled the RT scheduling in pulseaudios config.

Then I started Steam with
Code:
chrt -r 9 steam

and the result is horrible! I tried playing Left4Dead2 but can't join any server because of time outs. Single player loads extremely slow and what was micro-stuttering before hangs the game for multiple seconds now (sometimes it feels like the game runs with < 1 FPS).

So is RT gaming a complete disaster or am I doing something wrong? Does anyone have any experience with this?


Last edited by V10lator on Mon Jul 29, 2013 6:15 pm; edited 1 time in total
Back to top
View user's profile Send private message
Ant P.
Advocate
Advocate


Joined: 18 Apr 2009
Posts: 2221
Location: UK

PostPosted: Mon Jul 29, 2013 5:00 pm    Post subject: Reply with quote

You've forced X to use SCHED_RR's tiny timeslices while allowing it to cache-bounce all over the first 4 CPUs. Of course that's going to kill performance.
Back to top
View user's profile Send private message
V10lator
Apprentice
Apprentice


Joined: 11 Jul 2004
Posts: 166

PostPosted: Mon Jul 29, 2013 6:14 pm    Post subject: Reply with quote

Ant P. wrote:
You've forced X to use SCHED_RR's tiny timeslices while allowing it to cache-bounce all over the first 4 CPUs. Of course that's going to kill performance.

How to change that? But I also don't think this is the reason. Right now I give it a RT priority of 99, so the highest possible (I gave it 9 before, have to edit the OP) and the game works. But the higher I set the games priority the more things slow down (gave up waiting for it to start with a priority of 99).

Are there any gains from using RT at all? I thought latency should get better and micro-stuttering should be reduced.
Back to top
View user's profile Send private message
PaulBredbury
Watchman
Watchman


Joined: 14 Jul 2005
Posts: 7310

PostPosted: Tue Jul 30, 2013 1:35 am    Post subject: Reply with quote

In my experience, it's better to use SCHED_ISO for X and the game, which requires the BFS scheduler.

The BFS scheduler is much smoother for games. I use:

Code:
echo 4 > /proc/sys/kernel/rr_interval
echo 20 > /proc/sys/kernel/iso_cpu


Real-time is a can of worms, e.g. it's counter-productive for the game to be overriding the video card's interrupts. Or the USB interrupts from mouse movements.

I've documented this in scraps. One day I'll document it better...
_________________
Improve your font rendering and ALSA sound
Back to top
View user's profile Send private message
aCOSwt
Moderator
Moderator


Joined: 19 Oct 2007
Posts: 2388
Location: Hilbert space

PostPosted: Tue Jul 30, 2013 7:47 am    Post subject: Reply with quote

V10lator wrote:
Right now I give it a RT priority of 99, so the highest possible (I gave it 9 before, have to edit the OP) and the game works. But the higher I set the games priority the more things slow down (gave up waiting for it to start with a priority of 99).
Are there any gains from using RT at all? I thought latency should get better and micro-stuttering should be reduced.

1/ Giving the highest RT priority to X, your game... is absolutely wrong practice.
Highest RT priority of 99 should be reserved to the handlers of the interrupts which matter and to the watchdogs. Period.
2/ Giving whatever RT priority to a process that has not been especially designed for running in a RT environment will be of no help apart from... definitely screwing your entire system... sooner!
_________________
Back to top
View user's profile Send private message
V10lator
Apprentice
Apprentice


Joined: 11 Jul 2004
Posts: 166

PostPosted: Tue Aug 06, 2013 10:51 am    Post subject: Reply with quote

PaulBredbury wrote:
In my experience, it's better to use SCHED_ISO for X and the game, which requires the BFS scheduler.

The BFS scheduler is much smoother for games. I use:

Code:
echo 4 > /proc/sys/kernel/rr_interval
echo 20 > /proc/sys/kernel/iso_cpu


Real-time is a can of worms, e.g. it's counter-productive for the game to be overriding the video card's interrupts. Or the USB interrupts from mouse movements.

I've documented this in scraps. One day I'll document it better...

So I should revert the RT patch and apply BFS instead (AFAIK these two patches don't want to play nicely together) ? Thanks, will try that. :)

//EDIT: I did that now. But the only way I found to give X SCHED_ISO was:
Code:
schedtool -I -p 9 -n -10 `pidof X`

in my DEs autostart (XFCE4). I don't think this handles all of X threads. :( Also if I start steam with
Code:
schedtool -I -p 9 -n -10 -e steam

the performance seems to be worst than with the RT kernel (and a high RR priority for X).
Back to top
View user's profile Send private message
PaulBredbury
Watchman
Watchman


Joined: 14 Jul 2005
Posts: 7310

PostPosted: Tue Aug 06, 2013 12:40 pm    Post subject: Reply with quote

Your command is wrong - it errors out and does nothing.

Example to conveniently combine ionice and schedtool, so they both take effect:
Code:
ionice -c2 -n0 schedtool -I -e ut2004
Back to top
View user's profile Send private message
V10lator
Apprentice
Apprentice


Joined: 11 Jul 2004
Posts: 166

PostPosted: Tue Aug 06, 2013 10:27 pm    Post subject: Reply with quote

PaulBredbury wrote:
Your command is wrong - it errors out and does nothing.

Whoops, yea, I copied the "-p 9" by accident, without it works.
Quote:
Example to conveniently combine ionice and schedtool, so they both take effect:
Code:
ionice -c2 -n0 schedtool -I -e ut2004

What exactly does the ionice command do? I don't really understand the help of it. :/ Anyway: That works when you start something, I'm searching for a command that works for already started programs (and all of their tasks, like "chrt -a", but that can't handle SCHED_ISO).
Back to top
View user's profile Send private message
PaulBredbury
Watchman
Watchman


Joined: 14 Jul 2005
Posts: 7310

PostPosted: Wed Aug 07, 2013 3:21 am    Post subject: Reply with quote

V10lator wrote:
I'm searching

You seem to be a help vampire, but I'm feeling charitable. Another example:

Code:
p=`pidof X`
if [[ -n $p ]] ; then
    schedtool -I "$p"
    ionice -c2 -n0 -p "$p"
fi
Back to top
View user's profile Send private message
V10lator
Apprentice
Apprentice


Joined: 11 Jul 2004
Posts: 166

PostPosted: Wed Aug 07, 2013 3:25 am    Post subject: Reply with quote

@PaulBredbury Thanks for the try, but again: That's not what I'm searching:
V10lator wrote:
I'm searching for a command that works for already started programs (and all of their tasks, like "chrt -a", but that can't handle SCHED_ISO).


//EDIT: And not being able to understand the programs help ("-n, --classdata <num> scheduling class data" - what is scheduling class data, why is 0 the best?) is not equal to being a help vampire.
Back to top
View user's profile Send private message
PaulBredbury
Watchman
Watchman


Joined: 14 Jul 2005
Posts: 7310

PostPosted: Wed Aug 07, 2013 4:17 am    Post subject: Reply with quote

Use ps to get the list of threads/processes, then use the list with schedtool.
Back to top
View user's profile Send private message
V10lator
Apprentice
Apprentice


Joined: 11 Jul 2004
Posts: 166

PostPosted: Wed Aug 07, 2013 5:20 am    Post subject: Reply with quote

PaulBredbury wrote:
Use ps to get the list of threads/processes, then use the list with schedtool.

Okay, that shows that all threads have the same PID but different LWPs. Now I can't find a way to give LWPs to schedtool and ionice but AFAIK giving such tools the PID only affects the main thread only (that's why chrt has the -a flag). So still not helpful. :(
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gamers & Players All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum