Windows NT Sync Driver Proposed For The Linux Kernel - Better Wine Performance

Written by Michael Larabel in WINE on 24 January 2024 at 12:00 AM EST. 114 Comments
WINE
Following discussions from last year's Linux Plumbers Conference, a Windows NT synchronization primitive driver has been proposed for the Linux kernel. This driver would expose /dev/ntsync as a new character device for implementing some of the Windows NT synchronization primitives directly within the Linux kernel. In turn this would help the performance of some Windows games/applications running on Linux via Wine and in some cases would mean significantly better performance.

Elizabeth Figura of CodeWeavers who published the "request for comments" (RFC) to various Linux kernel mailing lists explained of the motivations for this synchronization primitive driver for targeting Windows NT kernel behavior:
"The Wine project emulates the Windows API in user space. One particular part of that API, namely the NT synchronization primitives, have historically been implemented via RPC to a dedicated "kernel" process. However, more recent applications use these APIs more strenuously, and the overhead of RPC has become a bottleneck.

The NT synchronization APIs are too complex to implement on top of existing primitives without sacrificing correctness. Certain operations, such as NtPulseEvent() or the "wait-for-all" mode of NtWaitForMultipleObjects(), require direct control over the underlying wait queue, and implementing a wait queue sufficiently robust for Wine in user space is not possible. This proposed driver, therefore, implements the problematic interfaces directly in the Linux kernel."

The initial proposed patch series is a set of 32 patches while 17 patches are of the actual implementation. With these "NTSYNC" kernel driver patches there are benefits to different Windows games on Wine from 21% with Metro 2033 to as much as 678% with DiRT 3! Commonly this is helping games by upwards of 100%+ better performance.

Some of the performance numbers shared by Figura:

NTSYNC performance benefits


This isn't an entirely new concept as going back years Wine developers have sought a new Linux kernel sync API that's better than esync/fsync to handle the Windows NT synchronization object API needs.

It will be very interesting to see where this NT synchronization primitive driver work leads and if/when it will ultimately be accepted into the mainline Linux kernel for enhancing the performance of running Windows games/applications on Linux. In any event as this series is marked "RFC" and there are some open design elements to its implementation, it may take some revisions before settling down on something that could be upstreamed.

See this patch series for the initial RFC work. Embedded below is also the LPC 2023 presentation on the topic.

Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week