Exactly what is PLINQ?

19,412

Solution 1

This is Parallel LINQ. It's a way to run LINQ queries in parallel on multi-core/multi-processor systems, in order to (hopefully) speed them up.

There is a good article on this in MSDN Magazine.

For current details and plans, I recommend reading articles on the Parallel Programming with .NET Team Blog. They are the team implementing the parallel extensions, including PLINQ.

Solution 2

PLINQ is LINQ executed in Parallel, that is, using as much processing power as you have in your current computer.

If you have a computer with 2 cores like a dual core processor you'll get your Language Integrated Query operators do the work in parallel using both cores.

Using "only" LINQ you won't get as much performance because the standard Language Integrated Query operators won't parallelize your code. That means your code will run in a serial fashion not taking advantage of all your available processor cores.

There are lots of PLINQ query operators capable of executing your code using well known parallel patterns.

Take a look at my blog post in which I show the speed up you get when you run a simple LINQ query in Parallel using the AsParallel extension method:

Parallel LINQ (PLINQ) with Visual Studio 2010/2012 - Perf testing

If you want to go deep using PLINQ, I advise you to read:

Patterns for Parallel Programming: Understanding and Applying Parallel Patterns with the .NET Framework 4

Solution 3

It is a library that allows you to take a normal LINQ query, divide it into smaller tasks and execute each individual task on multiple threads taking advantage of processor cores.

Solution 4

It allows you to add .AsParallel to your LINQ to attempt to execute the query using as many processors as possible. Neat, but you still need to know a bit about whether your algorithm is "parallelisable" - it isn't magic.

It basically removes the need to manage a thread pool and manages synchronising the results coming back from each thread - normally without the parallel extensions library you would have to do this manually.

Solution 5

From Wikipedia's Parallel Extensions:

Parallel LINQ (PLINQ) is a concurrent query execution engine for LINQ, parallelizing the execution of queries on objects (LINQ to Objects) and XML data (LINQ to XML). PLINQ is intended for exposing data parallelism by use of queries. Any computation on objects that has been implemented as queries can be parallelized by PLINQ. However, the objects need to implement the IParallelEnumerable interface, which is defined by PLINQ itself. Internally it uses TPL for execution.

Share:
19,412
Alon Gubkin
Author by

Alon Gubkin

Updated on June 14, 2022

Comments

  • Alon Gubkin
    Alon Gubkin almost 2 years

    PLINQ was added in the .NET 4.0 Framework as an extension to LINQ.

    • What is it?
    • What problems does it solve?
    • When is it appropriate and when not?
  • Reed Copsey
    Reed Copsey over 14 years
    Parallel Extensions != PLINQ. PLINQ is one small portion of the new Parallel Extensions being added to .NET 4, but not, by any means, all of the PFX work.
  • Greg
    Greg over 14 years
    @Reed Of course. I was merely linking to Wikipedia, which is the third result of a Google query for "PLINQ" and has a section on Parallel LINQ. It was a trivial answer to a trivial question.
  • Bernhard Hofmann
    Bernhard Hofmann over 8 years
    The MSDN Magazine doesn't deep link to an article, but the blog is still good, so you still get my up vote.
  • Si8
    Si8 almost 7 years
    Keep in mind, not everything has a .AsParallel for LINQ, a good example is DataTable.
  • Legends
    Legends over 4 years
    Using PLINQ makes only sense for CPU bound tasks, right?