From 3db33c38695422639a881d3b693562326a670ace Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Fri, 17 Jun 2016 12:34:40 -0400 Subject: [PATCH] Reduce PLINQ tests outerloop from ~250s to ~85s The tests have been overhauled and are in fairly decent shape, so there wasn't as much low-hanging fruit as in some of the other test libraries, but there are still a few notable places we can make improvements and others we can cut back without losing quality of coverage. Changes: - Even though some care had been taken to avoid it, at least one DegreeOfParallelismTests was taking an extra ~25s on my machine waiting for the thread pool to ramp up. Fixed via the same helper used in other test libs. - Removed ReadOnlyCollection as a source. There are special PLINQ code paths for arrays, lists, ParallelEnumerable.Range, and custom partitioners, but not for other collection types, so I've commented out that source until such time as we do have such special cases. This removes ~1/6th of the test cases and an equivalent amount of execution time. - Improved throughput of the IntegerRangeSet helper, which is used in lots of tests and was a source of significant contention due to a lock used in the main Add method. Replacing it with a SpinLock reduced execution time by ~10%. - Removed ParallelEnumerable.Range as an "expander" in the SelectSelectManyTests. The delegate is returning an IEnumerable, so subsequent operations performed on the expander aren't continuing the PLINQ execution and are instead starting a new one, making this essentially equivalent to (but more expensive than and duplicative of) the Enumerable.Range expander that already exists. - Lowered outerloop default iteration count from 64K*ProcCount to 16K*ProcCount - Lowered OrderByThenByTest outerloop iteration count from 32K to 16K, and removed the additional 1K iteration count being performed. Commit migrated from https://github.com/dotnet/corefx/commit/2a75aefbe2cd8c951ac3cfb8ab2ea324847ae90c --- .../tests/System/Threading/ThreadPoolHelpers.cs | 47 ++++-- .../tests/Combinatorial/SourcesAndOperators.cs | 7 +- .../tests/DegreeOfParallelismTests.cs | 90 +++------- .../tests/Helpers/IntegerRangeSet.cs | 33 ++-- .../System.Linq.Parallel/tests/Helpers/Sources.cs | 5 +- .../tests/Helpers/UnorderedSources.cs | 4 +- .../tests/QueryOperators/OrderByThenByTests.cs | 185 +++++++++++---------- .../tests/QueryOperators/SelectSelectManyTests.cs | 1 - .../tests/System.Linq.Parallel.Tests.csproj | 3 + 9 files changed, 189 insertions(+), 186 deletions(-) diff --git a/src/libraries/Common/tests/System/Threading/ThreadPoolHelpers.cs b/src/libraries/Common/tests/System/Threading/ThreadPoolHelpers.cs index 6037a24..11ce0ab 100644 --- a/src/libraries/Common/tests/System/Threading/ThreadPoolHelpers.cs +++ b/src/libraries/Common/tests/System/Threading/ThreadPoolHelpers.cs @@ -8,26 +8,51 @@ namespace System.Threading { internal static class ThreadPoolHelpers { - internal static void EnsureMinThreadsAtLeast(int minWorkerThreads) - { - // Until ThreadPool.Get/SetMinThreads are exposed, we try to access them via reflection. + // Until ThreadPool.Get/SetMinThreads are exposed, we try to access them via reflection. + + private static readonly Type _threadPool = typeof(object).GetTypeInfo().Assembly.GetType("System.Threading.ThreadPool"); + private static readonly MethodInfo _getMinThreads = _threadPool?.GetTypeInfo().GetMethod("GetMinThreads"); + private static readonly MethodInfo _setMinThreads = _threadPool?.GetTypeInfo().GetMethod("SetMinThreads"); - Type threadPool = typeof(object).GetTypeInfo().Assembly.GetType("System.Threading.ThreadPool"); - MethodInfo getMinThreads = threadPool?.GetTypeInfo().GetMethod("GetMinThreads"); - MethodInfo setMinThreads = threadPool?.GetTypeInfo().GetMethod("SetMinThreads"); - if (getMinThreads != null && setMinThreads != null) + internal static ThreadCountReset EnsureMinThreadsAtLeast(int minWorkerThreads) + { + if (_getMinThreads != null && _setMinThreads != null) { var threadCounts = new object[2]; - getMinThreads.Invoke(null, threadCounts); - + _getMinThreads.Invoke(null, threadCounts); int workerThreads = (int)threadCounts[0]; if (workerThreads < minWorkerThreads) { threadCounts[0] = minWorkerThreads; - setMinThreads.Invoke(null, threadCounts); + _setMinThreads.Invoke(null, threadCounts); + + return new ThreadCountReset(workerThreads, (int)threadCounts[1]); + } + } + + return default(ThreadCountReset); + } + + internal struct ThreadCountReset : IDisposable + { + private readonly bool _reset; + private readonly int _worker, _io; + + internal ThreadCountReset(int worker, int io) + { + _reset = true; + _worker = worker; + _io = io; + } + + public void Dispose() + { + if (_reset) + { + _setMinThreads?.Invoke(null, new object[] { _worker, _io }); } } } } -} \ No newline at end of file +} diff --git a/src/libraries/System.Linq.Parallel/tests/Combinatorial/SourcesAndOperators.cs b/src/libraries/System.Linq.Parallel/tests/Combinatorial/SourcesAndOperators.cs index 114980d..57161ae 100644 --- a/src/libraries/System.Linq.Parallel/tests/Combinatorial/SourcesAndOperators.cs +++ b/src/libraries/System.Linq.Parallel/tests/Combinatorial/SourcesAndOperators.cs @@ -4,7 +4,6 @@ using System.Collections.Concurrent; using System.Collections.Generic; -using System.Collections.ObjectModel; using Xunit; namespace System.Linq.Parallel.Tests @@ -30,9 +29,11 @@ namespace System.Linq.Parallel.Tests yield return Label("ParallelEnumerable.Range", (start, count, ignore) => ParallelEnumerable.Range(start, count)); yield return Label("Enumerable.Range", (start, count, ignore) => Enumerable.Range(start, count).AsParallel()); yield return Label("Array", (start, count, ignore) => Enumerable.Range(start, count).ToArray().AsParallel()); - yield return Label("Partitioner", (start, count, ignore) => Partitioner.Create(Enumerable.Range(start, count).ToArray()).AsParallel()); yield return Label("List", (start, count, ignore) => Enumerable.Range(start, count).ToList().AsParallel()); - yield return Label("ReadOnlyCollection", (start, count, ignore) => new ReadOnlyCollection(Enumerable.Range(start, count).ToList()).AsParallel()); + yield return Label("Partitioner", (start, count, ignore) => Partitioner.Create(Enumerable.Range(start, count).ToArray()).AsParallel()); + + // PLINQ doesn't currently have any special code paths for readonly collections. If it ever does, this should be uncommented. + // yield return Label("ReadOnlyCollection", (start, count, ignore) => new System.Collections.ReadOnlyCollection(Enumerable.Range(start, count).ToList()).AsParallel()); } private static IEnumerable> RangeSources() diff --git a/src/libraries/System.Linq.Parallel/tests/DegreeOfParallelismTests.cs b/src/libraries/System.Linq.Parallel/tests/DegreeOfParallelismTests.cs index dace802..c1ecb59 100644 --- a/src/libraries/System.Linq.Parallel/tests/DegreeOfParallelismTests.cs +++ b/src/libraries/System.Linq.Parallel/tests/DegreeOfParallelismTests.cs @@ -5,16 +5,12 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Threading; -using System.Threading.Tasks; using Xunit; namespace System.Linq.Parallel.Tests { public static class DegreeOfParallelismTests { - // If ThreadPool becomes available, uncomment the below - //private static ThreadPoolManager _poolManager = new ThreadPoolManager(); - public static IEnumerable DegreeData(int[] counts, int[] degrees) { foreach (object[] results in UnorderedSources.Ranges(counts.DefaultIfEmpty(Sources.OuterLoopCount), x => degrees.DefaultIfEmpty(x))) @@ -52,54 +48,51 @@ namespace System.Linq.Parallel.Tests } [Theory] - [MemberData(nameof(DegreeData), new[] { 1, 4, 32 }, new int[] { })] + [MemberData(nameof(DegreeData), new[] { 1, 4, 32 }, new int[] { /* same as count */ })] [OuterLoop] public static void DegreeOfParallelism_Barrier(Labeled> labeled, int count, int degree) { - Barrier barrier = new Barrier(degree); - //If ThreadPool becomes available, uncomment the below. - //_poolManager.ReserveThreads(degree); - //try - //{ - Assert.Equal(Functions.SumRange(0, count), labeled.Item.WithDegreeOfParallelism(degree).Sum(x => { barrier.SignalAndWait(); return x; })); - //} - //finally - //{ - // _poolManager.ReleaseThreads(); - //} + using (ThreadPoolHelpers.EnsureMinThreadsAtLeast(degree)) + { + var barrier = new Barrier(degree); + Assert.Equal(Functions.SumRange(0, count), labeled.Item.WithDegreeOfParallelism(degree).Sum(x => { barrier.SignalAndWait(); return x; })); + } } [Theory] - [MemberData(nameof(DegreeData), new int[] { /* Sources.OuterLoopCount */ }, new[] { 1, 4, 64, 512 })] + [MemberData(nameof(DegreeData), new int[] { /* Sources.OuterLoopCount */ }, new[] { 1, 4, 64, 128 })] [OuterLoop] public static void DegreeOfParallelism_Pipelining(Labeled> labeled, int count, int degree) { - Assert.True(labeled.Item.WithDegreeOfParallelism(degree).Select(x => -x).OrderBy(x => x).SequenceEqual(ParallelEnumerable.Range(1 - count, count).AsOrdered())); + using (ThreadPoolHelpers.EnsureMinThreadsAtLeast(degree)) + { + int expected = 1 - count; + foreach (int result in labeled.Item.WithDegreeOfParallelism(degree).Select(x => -x).OrderBy(x => x)) + { + Assert.Equal(expected++, result); + } + } } [Theory] - [MemberData(nameof(DegreeData), new[] { 1, 4 }, new int[] { })] + [MemberData(nameof(DegreeData), new[] { 1, 4 }, new int[] { /* same as count */ })] [MemberData(nameof(DegreeData), new[] { 32 }, new[] { 4 })] - // Without the ability to ask the thread pool to create a minimum number of threads ahead of time, - // higher thread counts take a prohibitive amount of time spooling them up. - //[MemberData(nameof(DegreeSourceData), new[] { 64, 512 }, new object[] { })] [OuterLoop] public static void DegreeOfParallelism_Throttled_Pipelining(Labeled> labeled, int count, int degree) { - // If ThreadPool becomes available, uncomment the below. - //_poolManager.ReserveThreads(degree); - //try - //{ - Assert.True(labeled.Item.WithDegreeOfParallelism(degree).Select(x => { Task.Delay(100).Wait(); return -x; }).OrderBy(x => x).SequenceEqual(ParallelEnumerable.Range(1 - count, count).AsOrdered())); - //} - //finally - //{ - // _poolManager.ReleaseThreads(); - //} + using (ThreadPoolHelpers.EnsureMinThreadsAtLeast(degree)) + { + Assert.True(labeled.Item.WithDegreeOfParallelism(degree).Select(x => + { + var sw = new SpinWait(); + while (!sw.NextSpinWillYield) sw.SpinOnce(); // brief spin to wait a small amount of time + return -x; + }).OrderBy(x => x).SequenceEqual(ParallelEnumerable.Range(1 - count, count).AsOrdered())); + } } [Theory] - [MemberData(nameof(NotLoadBalancedDegreeData), new[] { 1, 4 }, new int[] { })] + [MemberData(nameof(NotLoadBalancedDegreeData), new[] { 1, 4 }, new int[] { /* same as count */ })] [MemberData(nameof(NotLoadBalancedDegreeData), new[] { 32, 512, 1024 }, new[] { 4, 16 })] [OuterLoop] public static void DegreeOfParallelism_Aggregate_Accumulator(Labeled> labeled, int count, int degree) @@ -117,7 +110,7 @@ namespace System.Linq.Parallel.Tests } [Theory] - [MemberData(nameof(NotLoadBalancedDegreeData), new[] { 1, 4 }, new int[] { })] + [MemberData(nameof(NotLoadBalancedDegreeData), new[] { 1, 4 }, new int[] { /* same as count */ })] [MemberData(nameof(NotLoadBalancedDegreeData), new[] { 32, 512, 1024 }, new[] { 4, 16 })] [OuterLoop] public static void DegreeOfParallelism_Aggregate_SeedFunction(Labeled> labeled, int count, int degree) @@ -156,34 +149,5 @@ namespace System.Linq.Parallel.Tests { Assert.Throws("source", () => ((ParallelQuery)null).WithDegreeOfParallelism(2)); } - - // ThreadPool is not currently exposed. - // When available, uncomment below to reserve threads (should help test run time). - /* - private class ThreadPoolManager - { - private int _minWorker; - private int _minAsyncIO; - private int _maxWorker; - private int _maxAsyncIO; - - private object _switch = new object(); - - public void ReserveThreads(int degree) - { - Monitor.Enter(_switch); - ThreadPool.GetMinThreads(out _minWorker, out _minAsyncIO); - ThreadPool.GetMaxThreads(out _maxWorker, out _maxAsyncIO); - ThreadPool.SetMinThreads(degree, _minAsyncIO); - } - - public void ReleaseThreads() - { - ThreadPool.SetMinThreads(_minWorker, _minAsyncIO); - ThreadPool.SetMaxThreads(_maxWorker, _maxAsyncIO); - Monitor.Exit(_switch); - } - } - */ } } diff --git a/src/libraries/System.Linq.Parallel/tests/Helpers/IntegerRangeSet.cs b/src/libraries/System.Linq.Parallel/tests/Helpers/IntegerRangeSet.cs index 1779182..ffc4aea 100644 --- a/src/libraries/System.Linq.Parallel/tests/Helpers/IntegerRangeSet.cs +++ b/src/libraries/System.Linq.Parallel/tests/Helpers/IntegerRangeSet.cs @@ -10,28 +10,35 @@ using Xunit; namespace System.Linq.Parallel.Tests { // Dummy psuedo-set for verifying we've seen all of a range of integers, and only once. - internal class IntegerRangeSet : IEnumerable> + internal sealed class IntegerRangeSet : IEnumerable> { - private BitArray _seen; + private readonly BitArray _seen; private int _start; - private object _locker; + private SpinLock _lock = new SpinLock(enableThreadOwnerTracking: false); public IntegerRangeSet(int start, int count) { _start = start; _seen = new BitArray(count); - _locker = new object(); } public bool Add(int entry) { Assert.InRange(entry, _start, _start + _seen.Length - 1); - lock (_locker) - { - Assert.False(_seen[entry - _start]); - return _seen[entry - _start] = true; - } + bool seen; + + bool lockTaken = false; + _lock.Enter(ref lockTaken); + + int pos = entry - _start; + seen = _seen[pos]; + _seen[pos] = true; + + _lock.Exit(useMemoryBarrier: false); + + Assert.False(seen); + return true; } public void AssertComplete() @@ -49,10 +56,10 @@ namespace System.Linq.Parallel.Tests return GetEnumerator(); } - private class BitArrayEnumerator : IEnumerator> + private sealed class BitArrayEnumerator : IEnumerator> { private int _start; - private BitArray _values; + private readonly BitArray _values; private int _current = -1; @@ -96,9 +103,9 @@ namespace System.Linq.Parallel.Tests } // Simple class for counting the number of times an integer in a range has occurred. - internal class IntegerRangeCounter : IEnumerable> + internal sealed class IntegerRangeCounter : IEnumerable> { - private int[] _seen; + private readonly int[] _seen; private int _start; public IntegerRangeCounter(int start, int count) diff --git a/src/libraries/System.Linq.Parallel/tests/Helpers/Sources.cs b/src/libraries/System.Linq.Parallel/tests/Helpers/Sources.cs index ce65941..80f8f95 100644 --- a/src/libraries/System.Linq.Parallel/tests/Helpers/Sources.cs +++ b/src/libraries/System.Linq.Parallel/tests/Helpers/Sources.cs @@ -8,8 +8,9 @@ namespace System.Linq.Parallel.Tests { internal static class Sources { - // For outerloop, it's more important to saturate the processors/consumers and fill up buffers. - public static readonly int OuterLoopCount = 64 * 1024 * Environment.ProcessorCount; + // For outerloop, we use a large count that makes it more likely we'll fill buffers and saturate + // producers/consumers, while at the same time being cognizant of total test execution time. + public static readonly int OuterLoopCount = 16 * 1024 * Environment.ProcessorCount; private static readonly IEnumerable OuterLoopCounts = new[] { OuterLoopCount }; diff --git a/src/libraries/System.Linq.Parallel/tests/Helpers/UnorderedSources.cs b/src/libraries/System.Linq.Parallel/tests/Helpers/UnorderedSources.cs index 7a97031..2134162 100644 --- a/src/libraries/System.Linq.Parallel/tests/Helpers/UnorderedSources.cs +++ b/src/libraries/System.Linq.Parallel/tests/Helpers/UnorderedSources.cs @@ -238,7 +238,9 @@ namespace System.Linq.Parallel.Tests IList rangeList = rangeArray.ToList(); yield return Labeled.Label("List", rangeList.AsParallel()); yield return Labeled.Label("Partitioner", Partitioner.Create(rangeArray).AsParallel()); - yield return Labeled.Label("ReadOnlyCollection", new ReadOnlyCollection(rangeList).AsParallel()); + + // PLINQ doesn't currently have any special code paths for readonly collections. If it ever does, this should be uncommented. + // yield return Labeled.Label("ReadOnlyCollection", new ReadOnlyCollection(rangeList).AsParallel()); } } } diff --git a/src/libraries/System.Linq.Parallel/tests/QueryOperators/OrderByThenByTests.cs b/src/libraries/System.Linq.Parallel/tests/QueryOperators/OrderByThenByTests.cs index dbd2c70..b07e7e1 100644 --- a/src/libraries/System.Linq.Parallel/tests/QueryOperators/OrderByThenByTests.cs +++ b/src/libraries/System.Linq.Parallel/tests/QueryOperators/OrderByThenByTests.cs @@ -13,6 +13,7 @@ namespace System.Linq.Parallel.Tests { private const int KeyFactor = 4; private const int GroupFactor = 8; + private const int LongRunningCount = 16 * 1024; // Get ranges from 0 to each count. The data is random, seeded from the size of the range. public static IEnumerable OrderByRandomData(int[] counts) @@ -80,9 +81,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void OrderBy_Longrunning(Labeled> labeled, int count) { OrderBy(labeled, count); @@ -107,9 +108,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void OrderBy_Reversed_Longrunning(Labeled> labeled, int count) { OrderBy_Reversed(labeled, count); @@ -134,9 +135,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void OrderByDescending_Longrunning(Labeled> labeled, int count) { OrderByDescending(labeled, count); @@ -161,9 +162,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void OrderByDescending_Reversed_Longrunning(Labeled> labeled, int count) { OrderByDescending_Reversed(labeled, count); @@ -183,9 +184,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void OrderBy_NotPipelined_Longrunning(Labeled> labeled, int count) { OrderBy_NotPipelined(labeled, count); @@ -205,9 +206,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void OrderBy_Reversed_NotPipelined_Longrunning(Labeled> labeled, int count) { OrderBy_Reversed_NotPipelined(labeled, count); @@ -227,9 +228,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void OrderByDescending_NotPipelined_Longrunning(Labeled> labeled, int count) { OrderByDescending_NotPipelined(labeled, count); @@ -249,9 +250,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void OrderByDescending_Reversed_NotPipelined_Longrunning(Labeled> labeled, int count) { OrderByDescending_Reversed_NotPipelined(labeled, count); @@ -276,9 +277,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void OrderBy_CustomComparator_Longrunning(Labeled> labeled, int count) { OrderBy_CustomComparer(labeled, count); @@ -303,9 +304,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void OrderByDescending_CustomComparator_Longrunning(Labeled> labeled, int count) { OrderByDescending_CustomComparer(labeled, count); @@ -325,9 +326,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void OrderBy_NotPipelined_CustomComparator_Longrunning(Labeled> labeled, int count) { OrderBy_NotPipelined_CustomComparer(labeled, count); @@ -347,9 +348,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void OrderByDescending_NotPipelined_CustomComparator_Longrunning(Labeled> labeled, int count) { OrderByDescending_NotPipelined_CustomComparer(labeled, count); @@ -554,9 +555,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void ThenBy_Longrunning(Labeled> labeled, int count) { ThenBy(labeled, count); @@ -588,9 +589,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void ThenBy_Reversed_Longrunning(Labeled> labeled, int count) { ThenBy_Reversed(labeled, count); @@ -622,9 +623,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void ThenByDescending_Longrunning(Labeled> labeled, int count) { ThenByDescending(labeled, count); @@ -656,9 +657,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void ThenByDescending_Reversed_Longrunning(Labeled> labeled, int count) { ThenByDescending_Reversed(labeled, count); @@ -691,9 +692,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void ThenBy_NotPipelined_Longrunning(Labeled> labeled, int count) { ThenBy_NotPipelined(labeled, count); @@ -726,9 +727,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void ThenBy_Reversed_NotPipelined_Longrunning(Labeled> labeled, int count) { ThenBy_Reversed_NotPipelined(labeled, count); @@ -761,9 +762,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void ThenByDescending_NotPipelined_Longrunning(Labeled> labeled, int count) { ThenByDescending_NotPipelined(labeled, count); @@ -796,9 +797,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void ThenByDescending_Reversed_NotPipelined_Longrunning(Labeled> labeled, int count) { ThenByDescending_Reversed_NotPipelined(labeled, count); @@ -830,9 +831,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void ThenBy_CustomComparator_Longrunning(Labeled> labeled, int count) { ThenBy_CustomComparer(labeled, count); @@ -864,9 +865,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void ThenByDescending_CustomComparator_Longrunning(Labeled> labeled, int count) { ThenByDescending_CustomComparer(labeled, count); @@ -899,9 +900,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void ThenBy_NotPipelined_CustomComparator_Longrunning(Labeled> labeled, int count) { ThenBy_NotPipelined_CustomComparer(labeled, count); @@ -934,9 +935,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void ThenByDescending_NotPipelined_CustomComparator_Longrunning(Labeled> labeled, int count) { ThenByDescending_NotPipelined_CustomComparer(labeled, count); @@ -1014,9 +1015,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void ThenBy_ThenBy_Longrunning(Labeled> labeled, int count) { ThenBy_ThenBy(labeled, count); @@ -1042,9 +1043,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void ThenByDescending_ThenByDescending_Longrunning(Labeled> labeled, int count) { ThenByDescending_ThenByDescending(labeled, count); @@ -1071,9 +1072,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void ThenBy_ThenBy_NotPipelined_Longrunning(Labeled> labeled, int count) { ThenBy_ThenBy_NotPipelined(labeled, count); @@ -1100,9 +1101,9 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(OrderByRandomData), new[] { 1024, 1024 * 32 })] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(OrderByRandomData), new[] { LongRunningCount })] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void ThenByDescending_ThenByDescending_NotPipelined_Longrunning(Labeled> labeled, int count) { ThenByDescending_ThenByDescending_NotPipelined(labeled, count); @@ -1227,8 +1228,8 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void StableSort_Longrunning(Labeled> labeled, int count) { StableSort(labeled, count); @@ -1258,8 +1259,8 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void StableSort_NotPipelined_Longrunning(Labeled> labeled, int count) { StableSort_NotPipelined(labeled, count); @@ -1289,8 +1290,8 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void StableSort_Descending_Longrunning(Labeled> labeled, int count) { StableSort_Descending(labeled, count); @@ -1320,8 +1321,8 @@ namespace System.Linq.Parallel.Tests [Theory] [OuterLoop] - [MemberData(nameof(Sources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(Sources))] - [MemberData(nameof(UnorderedSources.Ranges), new[] { 1024, 1024 * 32 }, MemberType = typeof(UnorderedSources))] + [MemberData(nameof(Sources.Ranges), new[] { LongRunningCount }, MemberType = typeof(Sources))] + [MemberData(nameof(UnorderedSources.Ranges), new[] { LongRunningCount }, MemberType = typeof(UnorderedSources))] public static void StableSort_Descending_NotPipelined_Longrunning(Labeled> labeled, int count) { StableSort_Descending_NotPipelined(labeled, count); diff --git a/src/libraries/System.Linq.Parallel/tests/QueryOperators/SelectSelectManyTests.cs b/src/libraries/System.Linq.Parallel/tests/QueryOperators/SelectSelectManyTests.cs index f4722df..9a45fa4 100644 --- a/src/libraries/System.Linq.Parallel/tests/QueryOperators/SelectSelectManyTests.cs +++ b/src/libraries/System.Linq.Parallel/tests/QueryOperators/SelectSelectManyTests.cs @@ -266,7 +266,6 @@ namespace System.Linq.Parallel.Tests { yield return Labeled.Label("Array", (Func>)((start, count) => Enumerable.Range(start * count, count).ToArray())); yield return Labeled.Label("Enumerable.Range", (Func>)((start, count) => Enumerable.Range(start * count, count))); - yield return Labeled.Label("ParallelEnumerable.Range", (Func>)((start, count) => ParallelEnumerable.Range(start * count, count).AsOrdered().Select(x => x))); } [Theory] diff --git a/src/libraries/System.Linq.Parallel/tests/System.Linq.Parallel.Tests.csproj b/src/libraries/System.Linq.Parallel/tests/System.Linq.Parallel.Tests.csproj index d4cb282..4e61ebe 100644 --- a/src/libraries/System.Linq.Parallel/tests/System.Linq.Parallel.Tests.csproj +++ b/src/libraries/System.Linq.Parallel/tests/System.Linq.Parallel.Tests.csproj @@ -25,6 +25,9 @@ Common\System\ShouldNotBeInvokedException.cs + + CommonTest\System\Threading\ThreadPoolHelpers.cs + -- 2.7.4