Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,7 @@ private static partial class WorkerThread
{
private static readonly short ThreadsToKeepAlive = DetermineThreadsToKeepAlive();

Copy link

Copilot AI May 8, 2025

Choose a reason for hiding this comment

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

Consider adding a comment that explains the removal of the ARM-specific spin multiplier and notes the performance improvements observed, to aid future maintainers.

Suggested change
// The ARM-specific spin multiplier was removed to simplify the code and ensure consistent behavior across architectures.
// Performance testing showed that a default spin count of 70 provides optimal performance on both ARM and non-ARM platforms.

Copilot uses AI. Check for mistakes.

private const int SemaphoreSpinCountDefaultBaseline = 70;
#if !TARGET_ARM64 && !TARGET_ARM && !TARGET_LOONGARCH64
private const int SemaphoreSpinCountDefault = SemaphoreSpinCountDefaultBaseline;
#else
// On systems with ARM processors, more spin-waiting seems to be necessary to avoid perf regressions from incurring
// the full wait when work becomes available soon enough. This is more noticeable after reducing the number of
// thread requests made to the thread pool because otherwise the extra thread requests cause threads to do more
// busy-waiting instead and adding to contention in trying to look for work items, which is less preferable.
private const int SemaphoreSpinCountDefault = SemaphoreSpinCountDefaultBaseline * 4;
#endif
private const int SemaphoreSpinCountDefault = 70;

// This value represents an assumption of how much uncommitted stack space a worker thread may use in the future.
// Used in calculations to estimate when to throttle the rate of thread injection to reduce the possibility of
Expand Down
Loading