Task Parallel library implementation on mono?

2019-04-06 12:15发布

Does Mono implement Task Parallel library? If so, how does performance compare between .NET and mono.

3条回答
可以哭但决不认输i
2楼-- · 2019-04-06 12:27

This was implemented in Mono release 2.6.

From the release notes:

ParallelFx

This release includes some components of the ParallelFx framework that were developed as part of Google Summer Of Code 2008 & 2009. More precisely, it contains the Task Parallel Library and Data Structures For Coordination.

Using ParallelFx, you can easily develop software that can automatically take advantage of the parallel potential of today multicore machines. For that purpose, several new constructs like futures, parallel loops or concurrent collections are now available.

To use this code you have to manually enable the .NET 4 profile using the --with-profile4=yes switch at configure stage.

查看更多
做自己的国王
3楼-- · 2019-04-06 12:27

In my own experience, I have a highly parallel program in C# for the learning and classification of gene sequence data which makes very heavy usage of the Task Parallel Library features such as Parallel.ForEach, Parallel.For, Task.Factory.StartNew(), and many structures from from the Collections.Concurrent namespace (Blocking Collections, Concurrent Dictionaries, Concurrent Bags etc). In short, my application's performance on Linux using mono is many many times slower. I am still trying to figure this out. I can run it from the mono console in windows with similar performance.

I have experimented with using mono's sgen garbage collector to no avail. The performance of my application on a Linux server running with mono is still dramatically slower.

Learning 8,258 sequences: 0:17 vs. 1:59 m:ss on Linux

Classify 921 sequences: 2.29 seconds vs. 11:05 mm:ss on Linux

See screen shots below.

enter image description here
enter image description here

查看更多
你好瞎i
4楼-- · 2019-04-06 12:42

Did you try changing the min/maxthreads?

System.Threading.ThreadPool.SetMaxThreads(mWorker, mWorker);
System.Threading.ThreadPool.SetMinThreads(10, 10);

You are operating way beyond me, but I found that nothing was getting done. So I set it to 5 * number of cpu cores and it snapped right out of it!

查看更多
登录 后发表回答