You are not logged in.

#1 2010-12-29 17:58:43

karabaja4
Member
From: Croatia
Registered: 2008-09-14
Posts: 840

[SOLVED] Wine and process priority, trying to solve in-game stuttering

Hi,

the problem I'm trying to solve is stuttering in JK3: Jedi Academy game. This stuttering I would describe as FPS drops every 10-15 seconds which freezes the game for a short period of a second.
Stuttering is way more noticeable on kernel26-ck than it is on vanilla kernel26 (but it's still there), which leads me to believe it's related to CPU scheduler.

So, I started to mess with process priority. What I discovered confuses me however:

If I increase nice level and thus lower the process priority as far as it goes (priority in htop goes up - those with higher numbers have lower priority right?) game performance improves and stuttering is almost gone? (Unfortunately, it's still there. I'm trying to eliminate it...)

If I decreace nice level to -20, game is almost unplayable because of heavy stuttering??

What's the deal here? Why does niceness reverse-effect the performance from expected (increased priority, lower niceness = lower performance??)
This was all done on kernel26-ck 2.6.36.2.

Thanks.

Last edited by karabaja4 (2011-03-21 00:54:28)


pie!

Offline

#2 2010-12-30 02:20:59

rowdog
Member
From: East Texas
Registered: 2009-08-19
Posts: 79

Re: [SOLVED] Wine and process priority, trying to solve in-game stuttering

karabaja4 wrote:

If I increase nice level and thus lower the process priority as far as it goes (priority in htop goes up - those with higher numbers have lower priority right?) game performance improves and stuttering is almost gone? (Unfortunately, it's still there. I'm trying to eliminate it...)

If I decreace nice level to -20, game is almost unplayable because of heavy stuttering??

What's the deal here? Why does niceness reverse-effect the performance from expected (increased priority, lower niceness = lower performance??)

You've got it backwards. man nice says

Nicenesses  range from -20 (most favorable scheduling) to 19 (least favorable).

Offline

#3 2010-12-30 06:27:44

brebs
Member
Registered: 2007-04-03
Posts: 3,408

Re: [SOLVED] Wine and process priority, trying to solve in-game stuttering

karabaja4 wrote:

every 10-15 seconds

Interesting. Some CFS tweaks here.

However, I recommend you use the pf kernel, which includes BFS:

$ dmesg | grep -i koli
BFS CPU scheduler v0.360 by Con Kolivas.

As an example, here are the important bits of a script I use to play Command And Conquer 3:

# Yes, the ampersand at the end is crucial here
ionice -c2 wine CNC3 &

# Wait for adverts to finish, and main exe to start
sleep 30

schedtool -I $(pidof cnc3game.dat)
renice -n -2 -p $(pidof /usr/bin/wineserver)

Check the permissions with e.g.:

ps -eo pid,pri,nice,comm | grep wineser

You can also check whether you need to limit the game to the first CPU core:

taskset -c 0 /usr/bin/wine ...

Last edited by brebs (2010-12-30 06:29:08)

Offline

#4 2010-12-30 11:37:28

Gusar
Member
Registered: 2009-08-25
Posts: 3,413

Re: [SOLVED] Wine and process priority, trying to solve in-game stuttering

Do you have a multi-core processor? I've noticed with more than one game that binding it to a single core makes it work much better:

schedtool -a 0 -e wine somegame.exe

Offline

#5 2010-12-30 22:19:02

karabaja4
Member
From: Croatia
Registered: 2008-09-14
Posts: 840

Re: [SOLVED] Wine and process priority, trying to solve in-game stuttering

@rowdog: I know, I explained in detail that setting nice to least favorable scheduling IMPROVES game performance, which is odd. Hence my confusion.

@brebs: Ok, I read those links. Thing is, they are for an old version of kernels, and some of the options have changed. Anyway, as suggested:

a) on that wiki wow and in this thread on arch forums it says to:
a1) Recompile the kernel with CONFIG_SCHED_DEBUG option - this option is already enabled in mainstream ARCH kernel.
a2) Do this:

echo 21 > /proc/sys/kernel/sched_features
echo 25000000 > /proc/sys/kernel/sched_batch_wakeup_granularity_ns
echo 4000000 > /proc/sys/kernel/sched_min_granularity_ns

The thing is, sched_features doesn't exist anymore in newest kernels. sched_batch_wakeup_granularity_ns is now called sched_wakeup_granularity_ns. sched_min_granularity_ns is the same. I tried setting the latter two to suggested value, but it had no effect.

I also tried to play with ionice, nice, etc. no effect.
I only have 1 core so limiting would be pointless.

b) This seems to be this issue (thread on arch forums), however, the solutions there don't help (because of kernel changes?). Here another arch thread with the same problem. The last poster on that one noticed the same thing as I did - setting nice to 19 REDUCES the stutter, however it does not eliminate it.

***

And now some of my notes and observations:

1) This seems to be kernel (scheduler) related and not video related.
2) The stuttering is way more noticable on -ck patchset probably because of scheduler mehanics, and different timer frequency (100HZ vs 1000HZ I think).
3) I tried everything of the above on 2.6.37-rc8 (git tree), it's all the same.
4) Stutter on default arch or vanilla kernel is the same: it stutters every 15 seconds, which is alot better than on -ck kernel (every 2 seconds, but if I set niceness to 19 on ck kernel it gets the same as arch kernel). However, it's still not enough to play the game uninterrupted.

5) IMPORTANT: I noticed these drops in ALL openGL games (such as extremetuxracer), not just wine. Extremetuxracer on -ck patchset and default settings is UNPLAYABLE!

Anyway, this seems to be a larger issue than a simple Wine problem.

Last edited by karabaja4 (2010-12-30 22:26:13)


pie!

Offline

#6 2010-12-31 03:14:34

brebs
Member
Registered: 2007-04-03
Posts: 3,408

Re: [SOLVED] Wine and process priority, trying to solve in-game stuttering

I suggest you use the BFS scheduler, with these kernel options:

CONFIG_NO_HZ=y
CONFIG_HZ=1000
CONFIG_PREEMPT=y

And in xorg.conf:

Section "Extensions"
    Option      "Composite"    "false"
    Option      "DAMAGE"        "true"
EndSection

Because composite causes tearing.

And this kernel option in grub, which IIRC improved my smoothness, apparently because switching cores prevents the on-chip caching from being useful:  acpi_irq_nobalance
And when you do it, you might as well add these options also:  no-hlt nohalt

You seem to have an extreme case - does glxgears stutter? Is it locked to 60hz?

Do you have CPU power-saving enabled?
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
If so, disable it:
echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

Edit: Also, with BFS, 6 seems to be smoother than the default of 9 on my dual-core laptop:
echo 6 > /proc/sys/kernel/rr_interval

Last edited by brebs (2010-12-31 09:41:55)

Offline

#7 2011-03-21 00:05:48

karabaja4
Member
From: Croatia
Registered: 2008-09-14
Posts: 840

Re: [SOLVED] Wine and process priority, trying to solve in-game stuttering

I finaly solved this. The problem was that VMware installer has put this in /etc/sysctl.conf:

# Automatically generated by the VMware Installer - DO NOT REMOVE
kernel.sched_compat_yield=1
# Automatically generated by the VMware Installer - DO NOT REMOVE

Activating kernel.sched_compat_yield caused the stuttering! Argh! It's disabled by kernel default.
Apperantly it has something to do with support for multicore VMs. I have single core anyway and my VMs work fine without it.

Anyway, I can finally enjoy 3D wine smile

brebs wrote:

I suggest you use the BFS scheduler, with these kernel options:

CONFIG_NO_HZ=y
CONFIG_HZ=1000
CONFIG_PREEMPT=y

I have been using BFS for quite a while before 2.6.38... the situation there was better but that weird yield option was still in the way.

brebs wrote:

And in xorg.conf:

Section "Extensions"
    Option      "Composite"    "false"
    Option      "DAMAGE"        "true"
EndSection

Because composite causes tearing.

Thank you for this! I can't believe how my system beahves better without compositing. I get double framerate in 3D apps, and videos have absolutely no tearing (I was getting used to fact that video tearing is a price to pay for using linux).

Anyway thanks all!


pie!

Offline

Board footer

Powered by FluxBB