PLINQ

PLINQ (Parallel LINQ, pronounced “plink”) allows a program to execute LINQ queries across multiple processors or cores in a multi-core system. If you have a multi-core CPU and a nicely parallelizable query, PLINQ may improve your performance considerably.

So what kinds of queries are “nicely parallelizable”? The short, glib answer is, it doesn’t really matter. Microsoft has gone to great lengths to minimize the overhead of PLINQ, so using PLINQ may help for some queries and shouldn’t hurt you too much for queries that don’t parallelize nicely.

Simple queries that select items from a data source often work well. If the items in the source can be examined, selected, and otherwise processed independently, then the query is parallelizable.

Queries that must use multiple items at the same time do not parallelize nicely. For example, adding an OrderBy function to the query forces the program to gather all of the results before sorting them so that part of the query at least will not benefit from PLINQ.

THE NEED FOR SPEED
Some feel that adding parallelism to LINQ is kind of like giving caffeine to a snail. A snail is slow. Giving it caffeine might speed it up a bit, but you’d get a much bigger performance gain if you got rid of the snail and got a cheetah instead.
Similarly, LINQ isn’t all that fast. Adding parallelism will speed it up but you will probably get a larger speed improvement by moving the data into a database or using special-purpose algorithms designed to manage ...

Get Visual Basic 2012 Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.