Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
da29c61
Add dependencies
Mar 4, 2020
423d830
Add config var
Mar 4, 2020
ad228ef
Move portable RegisteredWaitHandle implementation to shared ThreadPoo…
Mar 9, 2020
1155fb0
Merge RegisteredWaitHandle implementations
Mar 4, 2020
6f9b3dc
Separate portable-only portion of RegisteredWaitHandle
May 24, 2020
d792cd7
Fix timers, tiered compilation, introduced time-sensitive work item q…
Mar 15, 2020
a911883
Implement ResetThreadPoolThread, set thread names for diagnostics
Mar 15, 2020
40ce9d0
Cache-line-separate PortableThreadPool._numRequestedWorkers similarly…
Mar 16, 2020
a5d3c2b
Post wait completions to the IO completion port on Windows for corecl…
Mar 17, 2020
ad632be
Reroute managed gate thread into unmanaged side to perform gate activ…
Mar 18, 2020
f942773
Flow config values from CoreCLR to the portable thread pool for compat
Mar 22, 2020
0ef2079
Port - 44970522045f0c323f5735c4fe4b54bd8f71e800 - Fix hill climbing f…
Mar 23, 2020
3151057
Port - aa5ce2b1bc9ac553ddd493e269a53c999d61e965 - Limit min threads i…
Mar 23, 2020
5d8d4ae
Port - 8cc2aa35933677339b9e9ec5485754aa750907df - Optimize AdjustMaxW…
Mar 24, 2020
3916619
Fix ETW events
Mar 25, 2020
88ea9c4
Fix perf of counts structs
Mar 27, 2020
8ef63f9
Fix perf of dispatch loop
Mar 28, 2020
e01df4f
Fix perf of ThreadInt64PersistentCounter
Mar 29, 2020
7c89f81
Miscellaneous perf fixes
Apr 1, 2020
13c2d62
Fix starvation heuristic
Jun 1, 2020
dd23472
Implement worker tracking
May 23, 2020
6cd2b2d
Use smaller stack size for threads that don't run user code
May 27, 2020
c8bdfad
Note some SOS dependencies, small fixes in hill climbing to make equi…
Jun 1, 2020
38c00d5
Port some tests from CoreRT
Jun 7, 2020
0ff3b03
Fail-fast in thread pool native entry points specific to thread pool …
Jun 7, 2020
cc35f92
Fix SetMinThreads() and SetMaxThreads() to return true only when both…
Jun 8, 2020
79eb3b9
Fix registered wait removals for fairness since there can be duplicat…
Jun 9, 2020
8b309cc
Allow multiple DotNETRuntime event providers/sources in EventPipe
Jun 12, 2020
ac1917d
Fix registered wait handle timeout logic in the wait thread
Jun 16, 2020
73f911c
Fix Browser build
Jun 22, 2020
1b99da7
Remove unnecessary methods from Browser thread pool, address some fee…
Jun 24, 2020
17b3d2d
Fix build warning after merge
Jun 30, 2020
e8043ff
Address feedback for events, undo EventPipe change in mono, change ev…
Jun 30, 2020
8d9cc2d
Disable new timer test for browser
Jul 1, 2020
f03709b
Fix EventSource tests to expect the new provider name used in mono
Jul 1, 2020
ff48985
Revert event source name in mono to match coreclr
Jul 3, 2020
93563e6
Add issue link for prerequisites of enabling the portable thread pool…
Jul 3, 2020
100dad7
Address feedback
Jul 6, 2020
4c7f778
Fix race condition in registered wait unregister
Jul 11, 2020
d55c5fc
Fix a new issue in WaitThread after shifting items in arrays
Jul 12, 2020
996597f
Fix usage of LowLevelMonitor after rebase
Sep 10, 2020
82f7cda
Fix tests that use RemoteExecutor to include a test for whether it is…
Sep 11, 2020
b53a5b9
Fix build
Sep 11, 2020
7dcb267
Slight fix to starvation heuristic to be closer to what it was before
Sep 25, 2020
65840d8
Fix license headers in new files
Oct 9, 2020
fb28ad2
Address feedback
Oct 9, 2020
04326b6
Change pattern for accessing the event source for better ILLinker com…
Oct 16, 2020
ec038cf
Move hill climbing config reads into constructor instead of passing t…
Oct 16, 2020
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
Prev Previous commit
Next Next commit
Note some SOS dependencies, small fixes in hill climbing to make equi…
…valent to coreclr
  • Loading branch information
Koundinya Veluri committed Oct 20, 2020
commit c8bdfad1b1515b6159fafebea5d15b2adf0a63c1
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ public UnmanagedThreadPoolWorkItem(IntPtr callback, IntPtr state)

public static partial class ThreadPool
{
// SOS's ThreadPool command depends on this name
internal static readonly bool UsePortableThreadPool = InitializeConfigAndDetermineUsePortableThreadPool();

internal static bool SupportsTimeSensitiveWorkItems => UsePortableThreadPool;

// This needs to be initialized after UsePortableThreadPool above, as it may depend on UsePortableThreadPool and the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ internal partial class PortableThreadPool
/// </summary>
private partial class HillClimbing
{
private static readonly Lazy<HillClimbing> s_threadPoolHillClimber = new Lazy<HillClimbing>(CreateHillClimber, true);
public static HillClimbing ThreadPoolHillClimber => s_threadPoolHillClimber.Value;

private const int LogCapacity = 200;
private const int DefaultSampleIntervalMsLow = 10;
private const int DefaultSampleIntervalMsHigh = 200;

public static readonly bool IsDisabled = AppContextConfigHelper.GetBooleanConfig("System.Threading.ThreadPool.HillClimbing.Disable", false);

// SOS's ThreadPool command depends on this name
public static readonly HillClimbing ThreadPoolHillClimber = CreateHillClimber();

private static HillClimbing CreateHillClimber()
{
// Default values pulled from CoreCLR
Expand All @@ -38,8 +39,8 @@ private static HillClimbing CreateHillClimber()
maxSampleError: AppContextConfigHelper.GetInt32Config("System.Threading.ThreadPool.HillClimbing.MaxSampleErrorPercent", 15, false) / 100.0
);
}
private const int LogCapacity = 200;

// SOS's ThreadPool command depends on the enum values
public enum StateOrTransition
{
Warmup,
Expand All @@ -52,13 +53,14 @@ public enum StateOrTransition
ThreadTimedOut,
}

// SOS's ThreadPool command depends on the names of all fields
private struct LogEntry
{
public int tickCount;
public StateOrTransition stateOrTransition;
public int newControlSetting;
public int lastHistoryCount;
public double lastHistoryMean;
public float lastHistoryMean;
}

private readonly int _wavePeriod;
Expand Down Expand Up @@ -89,9 +91,9 @@ private struct LogEntry

private readonly Random _randomIntervalGenerator = new Random();

private readonly LogEntry[] _log = new LogEntry[LogCapacity];
private int _logStart;
private int _logSize;
private readonly LogEntry[] _log = new LogEntry[LogCapacity]; // SOS's ThreadPool command depends on this name
private int _logStart; // SOS's ThreadPool command depends on this name
private int _logSize; // SOS's ThreadPool command depends on this name

public HillClimbing(int wavePeriod, int maxWaveMagnitude, double waveMagnitudeMultiplier, int waveHistorySize, double targetThroughputRatio,
double targetSignalToNoiseRatio, double maxChangePerSecond, double maxChangePerSample, int sampleIntervalMsLow, int sampleIntervalMsHigh,
Expand Down Expand Up @@ -417,8 +419,8 @@ private void LogTransition(int newThreadCount, double throughput, StateOrTransit
entry.tickCount = Environment.TickCount;
entry.stateOrTransition = stateOrTransition;
entry.newControlSetting = newThreadCount;
entry.lastHistoryCount = ((int)Math.Min(_totalSamples, _samplesToMeasure) / _wavePeriod) * _wavePeriod;
entry.lastHistoryMean = throughput;
entry.lastHistoryCount = (int)(Math.Min(_totalSamples, _samplesToMeasure) / _wavePeriod) * _wavePeriod;
entry.lastHistoryMean = (float)throughput;

_logSize++;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ internal partial class PortableThreadPool
/// </summary>
private struct ThreadCounts
{
// SOS's ThreadPool command depends on this layout
private const byte NumProcessingWorkShift = 0;
private const byte NumExistingThreadsShift = 16;
private const byte NumThreadsGoalShift = 32;

private ulong _data;
private ulong _data; // SOS's ThreadPool command depends on this name

private ThreadCounts(ulong data) => _data = data;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ internal sealed partial class PortableThreadPool
private static object? t_completionCountObject;

#pragma warning disable IDE1006 // Naming Styles
// The singleton must be initialized after the static variables above, as the constructor may be dependent on them
// The singleton must be initialized after the static variables above, as the constructor may be dependent on them.
// SOS's ThreadPool command depends on this name.
public static readonly PortableThreadPool ThreadPoolInstance = new PortableThreadPool();
#pragma warning restore IDE1006 // Naming Styles

private int _cpuUtilization = 0;
private int _cpuUtilization = 0; // SOS's ThreadPool command depends on this name
private short _minThreads;
private short _maxThreads;
private readonly LowLevelLock _maxMinThreadLock = new LowLevelLock();
Expand All @@ -46,7 +47,7 @@ internal sealed partial class PortableThreadPool
private struct CacheLineSeparated
{
[FieldOffset(Internal.PaddingHelpers.CACHE_LINE_SIZE * 1)]
public ThreadCounts counts;
public ThreadCounts counts; // SOS's ThreadPool command depends on this name
[FieldOffset(Internal.PaddingHelpers.CACHE_LINE_SIZE * 2)]
public int lastDequeueTime;
[FieldOffset(Internal.PaddingHelpers.CACHE_LINE_SIZE * 3)]
Expand All @@ -61,7 +62,7 @@ private struct CacheLineSeparated
public int gateThreadRunningState;
}

private CacheLineSeparated _separated;
private CacheLineSeparated _separated; // SOS's ThreadPool command depends on this name
private long _currentSampleStartTime;
private readonly ThreadInt64PersistentCounter _completionCounter = new ThreadInt64PersistentCounter();
private int _threadAdjustmentIntervalMs;
Expand Down