Skip to content

Revert "A few fixes in the threadpool semaphore. Unify Windows/Unix implementation of LIFO policy." - #125193

Merged
agocke merged 1 commit into
mainfrom
revert-123921-lifo
Mar 5, 2026
Merged

Revert "A few fixes in the threadpool semaphore. Unify Windows/Unix implementation of LIFO policy."#125193
agocke merged 1 commit into
mainfrom
revert-123921-lifo

Conversation

@agocke

Copy link
Copy Markdown
Member

Reverts #123921

This change appears to have caused a large regression in NuGet restore performance. Reverting is confirmed to produce a significant improvement (10-15%).

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @VSadov
See info in area-owners.md if you want to be subscribed.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reverts PR #123921 which had unified the Windows/Unix LIFO semaphore implementation and introduced futex-based thread blocking. The revert is motivated by a confirmed 10-15% regression in NuGet restore performance caused by the original change. The revert restores the original platform-specific LowLevelLifoSemaphore implementations (IO Completion Port on Windows, WaitSubsystem on Unix), removes the futex infrastructure (LowLevelFutex, LowLevelThreadBlocker), and reverts the spinning heuristics and Backoff.Exponential changes.

Changes:

  • Restores platform-specific LowLevelLifoSemaphore implementations (LowLevelLifoSemaphore.Windows.cs using IO Completion Ports, LowLevelLifoSemaphore.Unix.cs using WaitSubsystem) and removes the unified futex-based thread blocking infrastructure.
  • Reverts the thread pool semaphore spinning strategy from an adaptive per-core-availability approach back to a simple configurable spin count with random exponential backoff.
  • Removes the Synchronization.lib dependency and WaitOnAddress/WakeByAddressSingle Win32 API usage across managed and native code.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 4 comments.

Show a summary per file
FileDescription
src/native/libs/System.Native/pal_threading.hRemoves futex function declarations
src/native/libs/System.Native/pal_threading.cRemoves futex function implementations (Linux syscall + fallback)
src/native/libs/System.Native/entrypoints.cRemoves futex DllImport entries
src/libraries/.../PortableThreadPool.WorkerThread.csReverts semaphore Wait call to 1-param, restores spin count config at call site
src/libraries/.../LowLevelThreadBlocker.csDeletes unified thread blocker class
src/libraries/.../LowLevelLifoSemaphore.csReverts to platform-dispatching partial class with simpler spin logic
src/libraries/.../LowLevelLifoSemaphore.Windows.csRestores IOCP-based Windows implementation
src/libraries/.../LowLevelLifoSemaphore.Unix.csRestores WaitSubsystem-based Unix implementation
src/libraries/.../LowLevelFutex.Windows.csDeletes Windows futex wrapper
src/libraries/.../LowLevelFutex.Unix.csDeletes Unix futex wrapper
src/libraries/.../Backoff.csReverts to void return, removes attempt>0 guard, restores max bits to 14
src/libraries/.../System.Private.CoreLib.Shared.projitemsUpdates build item includes for restored/removed files
src/libraries/.../Interop.WaitOnAddress.csDeletes WaitOnAddress/WakeByAddressSingle P/Invoke
src/libraries/.../Interop.CriticalSection.csRemoves [SuppressGCTransition] from LeaveCriticalSection
src/libraries/.../Interop.Libraries.csRemoves Synch library constant, adds duplicate Oleaut32
src/libraries/.../Interop.LowLevelMonitor.csRemoves [SuppressGCTransition] from LowLevelMonitor_Release
src/libraries/.../Interop.Futex.csDeletes futex P/Invoke declarations
src/coreclr/.../reproNative.vcxprojRemoves Synchronization.lib from SDK libs
src/coreclr/.../WindowsAPIs.txtRemoves WaitOnAddress/WakeByAddressSingle API entries
src/coreclr/.../Microsoft.NETCore.Native.Windows.targetsRemoves Synchronization.lib
docs/coding-guidelines/interop-guidelines.mdReverts documentation examples to pre-#123921 state

@agocke

Copy link
Copy Markdown
MemberAuthor

/ba-g known issue filed

@github-actionsgithub-actionsBot locked and limited conversation to collaborators Apr 5, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants

@agocke@jkotas