Hi,

I don't know why exactly performance degrades with more cores. But PSeq is simply a thin layer around parallel Linq, and I believe PLinq by default uses partitioning strategies which are probably not optimal for this problem.

Fortunately it is possible to customize this. Using a load-balancing partioner clearly improves performance even on my lowely 2-core machine. Example code:

1
2
3
4
5
6
7
8
 

let finalDigitOfPrimes = 
   System.Collections.Concurrent.Partitioner.Create(nums, loadBalance=true).AsParallel() 
   |> PSeq.filter isPrime 
   |> PSeq.groupBy (fun i -> i % 10) 
   |> PSeq.map (fun (k, vs) -> (k, Seq.length vs)) 
   |> PSeq.toArray 

Would be interesting to know how this performs on a 48-core machine...

By on 4/21/2011 12:35 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper