http://bugs.winehq.org/show_bug.cgi?id=13801
--- Comment #29 from Jan Ploski jpljpl@gmx.de 2008-09-14 10:38:50 --- (In reply to comment #28)
(In reply to comment #25)
Well, I guess the bottleneck is in X11DRV_LockDIBSection() and X11DRV_UnlockDIBSection().... Maybe some threading problem ? Disabling both functions speeds up stuffs of a factor of 50-100.... Of course with some quirks on font display.
I found a new way to reproduce this bug - not with AutoCAD, but with a free demo version of the game "The Spirit Engine 2". It can be obtained here: http://www.thespiritengine.com/tse2-download.html
This game is a nice test case because it is unbearably slow from the very start
- when it fades in a credits screen with some (Arial) text on it and the fade
is noticeably slow. The slowdown becomes much even more apparent during fight scenes in the game when a lot of text is rendered.
Commenting out the calls to X11DRV_LockDIBSection and X11DRV_UnlockDIBSection in X11DRV_XRender_ExtTextOut fixes the slowdowns, but it also makes all text disappear completely, so it is not an acceptable workaround.
(The description below refers to wine-1.1.4 source:)
I narrowed it down even more. Making X11DRV_DIB_Coerce to become a no-op has the same beneficial effect for performance (with the same side effect of text not being displayed at all).
The same effect wrt performance can be also achieved by commenting out the invocation of VirtualProtect in X11DRV_DIB_DoProtectDIBSection. However, this causes a great distortion in the displayed content (not just vanishing text).
Overall, it seems to me like some sort of lock contention problem, with NtProtectVirtualMemory being called a lot of times from the execution path containing DrawTextExA, X11DRV_XRender_ExtTextOut, X11DRV_LockDIBSection, X11DRV_DIB_Coerce.
Fixing this will require more insight into the DIB code than I have. I imagine that some cheaper alternative to the currently employed NtProtectVirtualMemory mechanism might exist.