How can a mutex in Wine be faster than a native one on Linux

3 lh_mouse 0 8/26/2025, 8:44:00 AM
System information

* CPU: 11th Gen Intel Core i7-1165G7

* System: Linux Mint 22.2

* Kernel: 6.11.0-1014-lowlatency (no ntsync)

* Sys libc: GNU C library 2.39

* Wine: 9.0

* Compiler: GCC 13 (both)

Configurations and time of execution (lower is better)

* linux std: ( 8.150 s) std::mutex, backed by pthread

* linux boost: (10.936 s) boost::mutex

* win std: (20.246 s) std::mutex, backed by CRITICAL_SECTION

* win boost: ( 4.849 s) boost::mutex

* win srw: (15.853 s) SRWLOCK

* win mcf0i: ( 4.117 s) _MCF_mutex from mcfgthread, inlining disabled

The test uses code from https://github.com/markwaterman/MutexShootout

Hyperfine screenshot: https://files.lhmouse.com/20250826-155709.png

When boost::mutex is compiled natively it's slower than glibc, but when it's compiled for Windows and run in Wine it outperforms everything except mcfgthread, including native glibc mutex. Does this mean the glibc mutex is inferior in design, or is it sorta magic in thread scheduling in Wine that makes boost::mutex behave better in this test?

Comments (0)

No comments yet