Now that Wine has matured to the point of running many applications correctly, people are expecting them to run as fast as on Windows. Sadly, this is not always the case. Here are a few notes related to tracking down performance issues.
Surprising as it may be, there really isn't a magic toggle to make everything faster. Anyway, for games, you can experiment with the following short list of settings:
You can see the specific error/problem titles on the right side as a list, if you know what is your problem you can jump straight to it. If you don't know what the hell is going on you can go to the last title at the end of the guide for an extensive general list of things to do.
otherwise
The rest of this document is meant for developers more than users.
Disclaimer: Some pages on this site may include an affiliate link. This does not effect our editorial in any way. Microsoft Visual C Runtime library Program C:/Program Files /internet explorer/explorer.exe This application has requiested the Runtime to terminate it in an unusual way.Please contact the application's support team for more information.
Here are some performance-related bugzilla queries:
The linux kernel might have something to do with performance. CONFIG_NO_HZ might make a difference, for instance.Here are a few notes on the subject:
If you're making a tweak that speeds up one application, you probably want to run a bunch of different performance benchmarks before and after, to make sure it doesn't slow other applications down.
Many benchmarks exist for Windows. ['yagmark'] is a shell script that knows how to download and run several of them.3DMark 06 in particular is a classic benchmark we'd like to do better on.
There are many profiling tools that can help find bottlenecks in Wine.
Here are a few that have been used with some success:
There are also a few graphic debug tools that might come in handy, like apitrace or renderdoc.
It's possible to build wined3d for Windows; this is cool because it might let you figure out if the bottleneck is in wined3d itself.
First, the bad news: Often there is not a magic bullet to improve performance. It needs careful debugging and may be tricky to fix.
Note that 'unlikely' below doesn't mean 'impossible', neither does 'likely' mean 'always'. Rules of thumb can be wrong, so some intuition, double-checking of assumptions and deviations from the guide are necessary.
1) Basic steps for debugging Direct3D performance problems:
Before digging too deep check a few common issues:
Some words about CSMT. The basic idea is to segregate wined3d's GL calls to a separate thread: wined3d functions indirectly called by the application threads queue messages to the command stream thread which, on its part, essentially keeps checking the queue and executing whatever instruction it finds there.
CSMT has been initially developed as a way to enhance wined3d performance, with the 'theory' being that by splitting the potentially expensive GL calls out of the application thread we can quickly return to the application code and hopefully lessen our CPU-side woes. That turned out to work pretty well but with a caveat: some commands (e.g. mapping buffers) actually NEED to wait for the operation to complete since they have to return data to the application. Without some 'tricks' when we get one of those commands we have to effectively wait until all the commands queued before it complete their execution, which means that the application thread has to block and wait, potentially throwing a lot of the performance improvement out of the window.
The version of CSMT initially introduced in 'official' Wine does without some of those tricks (specifically, those that weren't generally safe) and has some room for further performance improvements. It still works perfectly fine as a better replacement of the StrictDrawOrdering option.
2) GPU, CPU or sync limited?
3D rendering is a complex process where multiple components have to play together:
If your game slows down if you increase the screen resolution (or speeds up when you lower it) you are probably GPU limited. This is because the CPU rarely touches single pixels, so with increased resolution only the strain on the GPU increases. Exceptions may apply especially in older ddraw/d3d7 based games..
Figuring out if the issue is excessive synchronization is a bit harder. A significant portion of wined3d time being spent in wined3d_cs_mt_finish() (with CSMT enabled) might hint in this direction, although that isn't necessarily the case and there might be synchronization points hidden in other spots.
3a) GPU limited situation:
If you're GPU limited the problem could be inefficient shaders, or incorrectly configured render target formats. Try ARB shaders (if the game is happy with Shader Model 2.0 or you have a Nvidia GPU), and check logs for usage of 16 bit per channel or floating point render targets.
Unless you have a low end GPU or play at a very high resolution GPU limitations are rare. A seeming GPU limitation may also be a sign of a software rendering fallback in the fragment pipeline.
3b) CPU limitation
Most performance issues on Mid-End or High-End systems are CPU side bottlenecks. The problem can be in pretty much every component involved in running the game:
It is tricky to tell those apart. A useful first test is comparing the following 3 metrics:
If there is a noticeable difference between (1) and (2) the problem is likely in the 3D related parts(wined3d, OpenGL driver). That's because all the other components haven't been changed. If there is a noticeable difference between (2) and (3) the problem is either in the non-3D parts(Rest of Wine, Linux kernel, ...). Make sure the game runs in the same codepath in all 4(or 3) cases - some games can use both d3d9 and d3d10 for example.
A difference between (2) and (3) may also indicate a problem in the Linux 3D driver that does not occur on Windows. If you are using AMD's or Nvidia's binary drivers this is unlikely because the Windows and Linux drivers share a pretty big common core. On macOS there is less code sharing, so if you're debugging performance issues on macOS the difference between (3) and (4) can matter.
3c) Limited by CPU-GPU synchronization
Ideally GPU and CPU should run as independent of each other as possible, to allow them to work at the same time without interruptions and exploit the available resources to the fullest.It's the application that ultimately decides how to set up its rendering pipeline, which means that sometimes there isn't much that Wine can do to avoid costly CPU-GPU synchronization points. That's one more reason why comparing performance with Windows is important.Assuming a well-behaved application, wined3d should strive to avoid introducing its own synchronization points. To figure out if there is room for improvement, the only practical thing to do is to look at the d3d log by hand (probably with some additional traces around wined3d_cs_finish() or its callers or other interesting points). I've also found it useful to make a log with just those ad-hoc traces (so to not slow down the game too much) and check it 'realtime' with the game and maybe perf.
4) Profilers
Now that you have a rough idea if you're looking for issues in 3D or non 3D parts it's time to separate modules further. perf, sysprof or other profilers can help here.
Case A): 3D related problems:
The main question is if the GPU time is spent in wined3d.dll or the driver. If more than 5% CPU time are spent in wined3d this is suspicious. If a lot of CPU time is spent in the driver libraries(> 30% if you need some threshold) it may indicate a bug in the driver itself, or inefficient GL calls made by wined3d. With binary drivers the difference doesn't matter much since you can't change the driver anyway.
Specifically for CSMT, a high wined3d_cs_run() CPU usage most likely means that the command stream thread is spinning a lot waiting for new commands to execute. That in turn points to the application thread not being able to keep up with the pace of the command stream / GPU execution (possibly because of wined3d stuff in the application thread) or that there is a lot of synchronization with the command stream thread and the queue is flushed a lot. A lot of time being spent in wined3d_cs_emit_present(), instead, suggests that the command stream thread is the bottleneck. In turn, that might be busy on the GPU or CPU side. In the latter case, driver's threaded optimizations might help, if available.
Case B): Non 3D related problems:
Usual suspects are ntdll.dll, kernel32.dll, wineserver, various C/C++ runtime libraries, the Linux kernel. You may be able to use the native version of the library in Wine. If that fixes your issues you know where to fix it in Wine. Again note that a high CPU usage in the Linux kernel or in low level Wine libs may be caused by inefficient calls to that library from a higher level, so be careful before taking out the pitchforks.
5) Telling wined3d problems from driver problems
Telling those apart is not easy. A driver may not support OpenGL extensions used for speedups, causing high CPU usage in wined3d(e.g. GL_ARB_vertex_buffer_object, GL_ARB_vertey_array_bgra). WineD3D may make inefficient calls causing high CPU usage in the driver.
A rule of thumb way is to try a different GPU/driver. If a game is slow on Nvidia GPUs (compared to Windows) and fast on AMD GPUs (compared to Windows on the same card) then the problem may be in the driver. If you have a binary driver you may as well just assume that the problem is in wined3d since otherwise you're mostly out of luck anyway.
If you isolate a problem in the driver don't forget to report it to the driver vendor.
6) Other hints:
Tutorial by Stefan Dösinger