You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Update libcxx wait/notify_one/notify_all to use WaitOnAddress/WakeByAddressSingle/WakeByAddressAll on Windows #127221
Windows 8 had introduced the WaitOnAddress, WakeByAddressSingle, and WakeByAddressAll functions that can be used to implement __libcpp_platform_wait_on_address and __libcpp_platform_wake_by_address on Windows.
Should a Windows-specific implementation of __libcpp_platform_wait_on_address and __libcpp_platform_wake_by_address that uses the WaitOnAddress/WakeByAddressSingle/WakeByAddressAll APIs be added to libcxx/src/atomic.cpp (although this change requires Windows 8 or later or Windows Server 2012 or later)?
@ldionne Should I go ahead and implement __libcpp_platform_wait_on_address using WaitOnAddress on Windows and implement __libcpp_platform_wake_by_address using WakeByAddressSingle/WakeByAddressAll on Windows (this change will require Windows 8 or later along with linking with libsynchronization.a or synchronization.lib)?
Changes also need to be made to clang/lib/Driver/ToolChains/MinGW.cpp to ensure that C++ applications or DLL's that statically link against libc++ also link against libsynchronization.lib.
Any updates/progress here? I ran into this landmine a few days ago, where using std::atomic_flag wait()/notify_all() for thread synchronization resulted in a 2-3x overall program slowdown vs using std::condition_variable, due specifically to the very inefficient implementation here on Windows. The Microsoft STL has this implemented with a platform check, using WaitOnAddress / WakeByAddressSingle / WakeByAddressAll on Windows 8+, with an efficient fallback using some static memory to hold synchronization primitives for earlier platforms. It should be possible to do the same thing here.
Activity
johnplatts commentedon Mar 13, 2025
@ldionne Should I go ahead and implement __libcpp_platform_wait_on_address using WaitOnAddress on Windows and implement __libcpp_platform_wake_by_address using WakeByAddressSingle/WakeByAddressAll on Windows (this change will require Windows 8 or later along with linking with libsynchronization.a or synchronization.lib)?
Changes also need to be made to clang/lib/Driver/ToolChains/MinGW.cpp to ensure that C++ applications or DLL's that statically link against libc++ also link against libsynchronization.lib.
RogerSanders commentedon Oct 14, 2025
Any updates/progress here? I ran into this landmine a few days ago, where using std::atomic_flag wait()/notify_all() for thread synchronization resulted in a 2-3x overall program slowdown vs using std::condition_variable, due specifically to the very inefficient implementation here on Windows. The Microsoft STL has this implemented with a platform check, using WaitOnAddress / WakeByAddressSingle / WakeByAddressAll on Windows 8+, with an efficient fallback using some static memory to hold synchronization primitives for earlier platforms. It should be possible to do the same thing here.
[libc++] Improve performance of std::atomic_flag on Windows
[libc++] Improve performance of std::atomic_flag on Windows (#163524)