Hi everyone
I would like to try to help with improving the performance of StarCraft II on Wine. I'm working with a friend. Over the past couple of weeks, we have tried to read whatever documentation we could find. We have tried a couple of different approaches to profiling, without much success.
My friend got WineD3D running on Windows. We built Wine from current source code, tested this on two different configurations, and got similar results.
- my Core 2 E8500 + GeForce 9600GT + Windows XP x86 - his i5-2500 + GeForce 660 + Windows 7 x64
It looks like WineD3D is the cause of most of the performance difference. Windows with its own D3D gave us at least twice the frame rate of Windows + WineD3D. There is some difference between the numbers for Windows + WineD3D and Linux + Wine, but it's much smaller, i.e. something like 25%.
Can anyone offer some hints on how to find the most significant causes of the performance difference? Any tips for effective profiling or tracing?
Thanks.
-- graham
Am 14.03.2013 um 20:07 schrieb Graham Knap graham.knap@gmail.com:
I would like to try to help with improving the performance of StarCraft II on Wine. I'm working with a friend. Over the past couple of weeks, we have tried to read whatever documentation we could find. We have tried a couple of different approaches to profiling, without much success.
That's great :-)
Note however that improving performance is not a weekend's job. It needs a lot of careful profiling, testing and bugfixing.
Can anyone offer some hints on how to find the most significant causes of the performance difference? Any tips for effective profiling or tracing?
Depending on your settings, you may be CPU or GPU limited. A rule of thumb way to find out is to change the game's resolution - if increasing the resolution causes a big framerate drop, you're probably GPU limited. If the framerate stays the same, you're CPU limited.
In the GPU limited case, improving the situation requires a tedious work to find shaders that execute slower, finding out why they are slower and then fixing things. It also needs double-checking with other games and GPUs to make sure that you're not optimizing one game at the cost of another.
In the CPU limited case, I believe the main reason is that native is able to move a lot of the CPU-side work to a different thread, thus utilizing two CPU cores. You can test that theory by forcing Windows to run with one CPU only (use msconfig for that) and comparing performance again.
Aside of the worker thread, there may be some parts of the wined3d code that can be optimized. Like the GPU side work, this requires a lot of careful testing, fixing and double-checking.
Stefan
Stefan Dösinger wrote:
Note however that improving performance is not a weekend's job. It needs a lot of careful profiling, testing and bugfixing.
Of course. I'm also starting with no knowledge of D3D/OpenGL, so that's going to slow me down rather a lot.
Depending on your settings, you may be CPU or GPU limited.
As noted in Wine bug 24558, I find that need to use taskset to get any useful amount of performance.
$ taskset -a -p 2 `pidof SC2.exe` $ taskset -p 1 `pidof SC2.exe`
I am not sure that this is a Wine bug at all. I think it is merely a difference in the OS's scheduler and power management. SC2 probably should set thread CPU affinity, but I don't think it does that.
The graphic detail and display resolution settings in the game don't make a huge difference to the frame rate, so I think we're CPU-bound.
In the CPU limited case, I believe the main reason is that native is able to move a lot of the CPU-side work to a different thread, thus utilizing two CPU cores. You can test that theory by forcing Windows to run with one CPU only (use msconfig for that) and comparing performance again.
That makes a difference for sure. Frame rate during a small recorded battle:
* Linux + Wine: about 18 FPS * Windows XP (native D3D) with 1 core: about 48 FPS * Windows XP (native D3D) with 2 cores: about 67 FPS
We have spent some time with strace, latencytop, and WINEDEBUG, looking for ways to reduce latency and scheduler thrash. I don't think there is much room for optimization here. However, I would still like to know what is calling various functions that cause latency, such as Sleep() or anything that requires a server call. Does anyone know how I can get that information? (I just want to know whether the call is coming from SC2, or from somewhere within Wine.)
We have tried using Linux's "perf" tool to find out what code paths should be given attention first. However, even though I have compiled Wine with "-ggdb", perf seems unable to show symbols for some parts of Wine, notably ntdll and kernel32, but probably also others. Does anyone know why? Is there a workaround, or a better method altogether?
The "Performance" page on the Wine Wiki suggests that it may be possible to use Visual Studio's profiling tools. Can anyone offer any tips for compiling and profiling WineD3D with Visual Studio?
-- graham