About wineserver and winsock

Damjan Jovanovic damjan.jov at gmail.com
Mon May 26 11:31:35 CDT 2014

That wouldn't always work: in theory, DuplicateHandle() could transmit
the socket to another process, which wouldn't have the same ws2_32

We could speed up calls to the wineserver, which involve at least 4
system calls, 2 context switches, and 4 memory copies (in and out of
the UNIX socket's buffers), by porting the wineserver to be a kernel
module on the underlying *nix kernel, so that it only needs a single
system call, zero context switches, and zero memory copies. I know
Transgaming was considering this years ago - don't know how far they
got - but I imagine it to be extremely difficult. Maybe it's possible
to port only a small part of it that deals with performance critical
areas, like sockets and synchronization, while the rest stays running
as a user space application?


On Mon, May 26, 2014 at 5:10 PM, Bruno Jesus <00cpxxx at gmail.com> wrote:
> Hi all, after studying the ws2_32 dll code for some time while looking
> for ways to optimize it I started wondering why is the wineserver
> required (please don't stop reading yet).
> make test takes 45 seconds in my machine while it takes 25 seconds in
> a XP VM running on the same machine. The culprit is test_send() [1]
> which takes 24 seconds in wine and 1.8 seconds in windows.
> This long time is related to the 1 million recv() calls in
> test_send(). Each call to recv() has to call wineserver to do a
> enable_event(FD_READ) operation, if you comment that line out [2] wine
> magically takes 1.7 seconds, just like windows does (obviously
> commenting that line generaters other errors related to event
> sequences).
> So, in simple words: what if we move all wineserver socket code to a
> thread that is started in the ws2_32 DLL. I know this may sound very
> silly for the experienced wine developers, maybe some operations are
> impossible without the wineserver, maybe there is much more things
> affected, but I think it's better to ask and get crushed with
> (hopefully) constructive criticism than forget about the idea.
> My main objective with this is to speedup the whole implementation and
> properly implement the select call (different socket states result in
> different checks required) and WSACleanup call (which needs to close
> every open socket on last cleanup) and some other get/setsockopt
> stuff.
> [1] http://source.winehq.org/git/wine.git/blob/HEAD:/dlls/ws2_32/tests/sock.c#l4200
> [2] http://source.winehq.org/git/wine.git/blob/HEAD:/dlls/ws2_32/socket.c#l6684
> Best wishes,
> Bruno

More information about the wine-devel mailing list