Questions tagged [plinq]

PLINQ is a parallel query execution engine for LINQ. PLINQ supports the data parallelism pattern by adding additional syntax to allow queries to be declared as running in parallel.

PLINQ is a parallel query execution engine for . PLINQ supports the data parallelism pattern by adding additional syntax to allow queries to be declared as running in parallel.

Related Links

365 questions
13
votes
9 answers

PLINQ Performs Worse Than Usual LINQ

Amazingly, using PLINQ did not yield benefits on a small test case I created; in fact, it was even worse than usual LINQ. Here's the test code: int repeatedCount = 10000000; private void button1_Click(object sender, EventArgs e) { …
Graviton
  • 81,782
  • 146
  • 424
  • 602
13
votes
2 answers

How to run LINQ 'let' statements in parallel?

I have code like this: var list = new List {1, 2, 3, 4, 5}; var result = from x in list.AsParallel() let a = LongRunningCalc1(x) let b = LongRunningCalc2(x) select new {a, b}; Let's say the…
Lyall
  • 895
  • 9
  • 20
12
votes
6 answers

Ordered PLINQ ForAll

The msdn documentation about order preservation in PLINQ states the following about ForAll(). Result when the source sequence is ordered: Executes nondeterministically in parallel Result when the source sequence is unordered: Executes…
Steven Jeuris
  • 18,274
  • 9
  • 70
  • 161
12
votes
1 answer

List Contains() with PLinq?

let's say I have a big List List longList = new List(10000000) And I want to do the following query: bool found = longList.Contains(4345235234524245124L); Is there a way to use PLinq for that to let each thread search just a little…
Chris
  • 4,325
  • 11
  • 51
  • 70
11
votes
1 answer

"using static" kills AsParallel

In the following code, if you uncomment the "using static" line, the query will not run in parallel. Why? (Visual Studio Community 2019, .Net Core 3.1 / .Net 4.8) using System; using System.Diagnostics; using System.Linq; using…
Mike Tsayper
  • 1,686
  • 1
  • 17
  • 25
11
votes
3 answers

AsParallel () and Any()?

I've seen this code which check a condition using AsParallel() and Any() : bool IsAnyDeviceConnected() { return m_devices.Any(d => d.IsConnected); } and to make it faster : bool IsAnyDeviceConnected() { return m_devices.AsParallel().Any(d…
Royi Namir
  • 144,742
  • 138
  • 468
  • 792
10
votes
2 answers

Using AsSequential in order to preserve order

I am looking at this code var numbers = Enumerable.Range(0, 20); var parallelResult = numbers.AsParallel().AsOrdered() .Where(i => i % 2 == 0).AsSequential(); foreach (int i in parallelResult.Take(5)) Console.WriteLine(i); The…
MaPi
  • 1,601
  • 3
  • 31
  • 64
9
votes
3 answers

.NET 4 Parallel.ForEach and PLINQ: can they overwhelm the thread pool and kill the app performance?

The more I use Parallel.ForEach and PLINQ in my code, the more faces and code review push backs I am getting. So I wonder is there any reason for me NOT to use PLINQ, at extreme, on each LINQ statement? Can the runtime not be smart enough to start…
Schultz9999
  • 8,717
  • 8
  • 48
  • 87
9
votes
5 answers

Difference linq and plinq

What is the difference between these two? What is the best way to compare ? It is always better plinq ? When we use plinq ?
9
votes
2 answers

Using Parallel Linq Extensions to union two sequences, how can one yield the fastest results first?

Let's say I have two sequences returning integers 1 to 5. The first returns 1, 2 and 3 very fast, but 4 and 5 take 200ms each. public static IEnumerable FastFirst() { for (int i = 1; i < 6; i++) { if (i > 3) Thread.Sleep(200); …
Alex Norcliffe
  • 2,439
  • 2
  • 17
  • 21
9
votes
2 answers

Explain please AsParallel()

Can somebody explain me one thing. As I understand AsParallel() executes in own task. So, if query return huge amount of data the variable 'd' can be empty at time when 'foreach' started to execute Console.WriteLine? var integerList =…
user628147
  • 361
  • 1
  • 5
  • 7
9
votes
2 answers

When should I use AsParallel() in linq/plinq

I'm looking make use of the advantages of parallel programming in linq by using plinq, im not sure I understand the use entirely apart from the fact its going to make use of all cpu cores more efficiently so for a large query it might be quicker.…
Froggy
  • 91
  • 1
  • 2
9
votes
1 answer

Combining PLINQ with Async method

I'm trying to combine my PLINQ statement like this: Enumerable.Range(0, _sortedList.Count()).AsParallel().WithDegreeOfParallelism(10) .Select(i => GetTransactionDetails(_sortedList[i].TransactionID)) .ToList(); With an async…
User987
  • 3,663
  • 15
  • 54
  • 115
9
votes
2 answers

Has got any real benefit of PLINQ?

Recently I made a couple of measures about Linq and Plinq. I can't see in which situation has a real significant benefit of Plinq. I've found many examples such as: Enumerable.Range(0, 10000).AsParallel().ForAll(_ => Thread.Sleep(50000)); This is…
speti43
  • 2,886
  • 1
  • 20
  • 23
9
votes
1 answer

How can I prevent AppDomainUnloadedException after NUnit tests PLINQ code?

How can I diagnose and minimize or prevent AppDomainUnloadedException? NUnit 2.5.2 consistently throws AppDomainUnloadedException after long (>10s) tests involving PLINQ. Back in July 2008, Stephen Toub said: Yes, the scheduler in the CTP…
Garth Kidd
  • 7,264
  • 5
  • 35
  • 36
1
2
3
24 25