The data above it comes from a yield return, although parallel.foreach was still faster than doing it all in line. List<T> was much much faster, shaved 2000ms off of the process.
I read some of the books/articles mentioned and i've been following the parallel blog for ages. But that was back when 4.0 came out. This is the first time I have used 4.0 on a task that requires more than 3.5 syntax. I had forgotten alot of info. I must be getting old :( Davy Sent from my starfleet datapad. On 25 juin 2013, at 08:54, "Corneliu I. Tusnea" <[email protected]> wrote: Here is a very good (but very old) presentation about the PFX: http://blogesh.files.wordpress.com/2009/05/getting-the-most-out-of-pfx.pptx Slide 33 has the partitioning details. On Tue, Jun 25, 2013 at 4:45 PM, Corneliu I. Tusnea <[email protected]>wrote: > David/Greg, > > Ihe IEnumerable is not an issue with Parallel.ForEach. The PFX library > will look for few other interfaces for your object and decide the > partitioning strategy based on that. > There are multiple paritioners that will be picked up based on your source: > Range (used for IList), Chunk (used for IEnumerable - it's slow as it has > to wait for each object to partition), Stripe (optional), Hash (for joins). > http://blogs.msdn.com/b/pfxteam/archive/2007/12/02/6558579.aspx > http://blogs.msdn.com/b/pfxteam/archive/2011/11/11/10235999.aspx > > You can write your own custom partitioners if you know how the data is > structured and can optimize the partition allocation. > http://msdn.microsoft.com/en-us/library/dd560853.aspx > http://msdn.microsoft.com/en-us/library/dd997411.aspx > > > > > > > On Tue, Jun 25, 2013 at 3:46 PM, Greg Keogh <[email protected]> wrote: > >> 1. Don't use IEnumerable and Parallel.ForEach, List<T> is much faster. >>> >> >> I don't have the bigger picture here, but IEnumerable and >> Parallel.ForEach go together like pancakes and ice cream. I'm even getting >> into the habit these days of making public methods that return collections >> prefer to return IEnumerable<T>. This means I have the freedom to consume >> them in parallel processing. >> >> Albahari's book C# in a Nutshell discusses parallel processing in general >> in chapter 23, and the Parallel class in particular over 7 dense pages. >> Richter covers the general subject in chapter 26 with 5 pages on Parallel. >> I'm pretty sure all your issues will be clarified in these pages and >> they're a really good read. >> >> Cheers, >> Greg >> > >
