Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exactly what is PLINQ?

Tags:

c#

.net

linq

plinq

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?
like image 381
Alon Gubkin Avatar asked Nov 02 '09 19:11

Alon Gubkin


2 Answers

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.

like image 149
Reed Copsey Avatar answered Sep 21 '22 20:09

Reed Copsey


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

like image 42
Leniel Maccaferri Avatar answered Sep 21 '22 20:09

Leniel Maccaferri