parallel-extensions

Using Parallel Extensions with ThreadStatic attribute. Could it leak memory?

不羁岁月 提交于 2019-12-04 05:19:06
I'm using Parallel Extensions fairly heavily and I've just now encountered a case where using thread local storage might be sensible to allow re-use of objects by worker threads. As such I was looking at the ThreadStatic attribute which marks a static field/variable as having a unique value per thread. It seems to me that it would be unwise to use PE with the ThreadStatic attribute without any guarantee of thread re-use by PE. That is, if threads are created and destroyed to some degree would the variables (and thus objects they point to) remain in thread local storage for some indeterminate

Parallel Extensions

喜你入骨 提交于 2019-12-03 16:12:59
I have an application with heavy IO operations such as file copying, zipping and moving the files around the file system, copying to backup servers. I build this program as single threaded. It runs in 2 minutes. I built another version of this program with Parallel extensions and using Task, which runs almost in 2 minutes as well. In other words I didnt see a performance gain by using Parallels due to heavy IO. Would I get the same results if i deploy the application to a blade server? Does blade servers process IO faster/ on multi channels than my workstation? There is no benefit of using

Task Parallel Library - Custom Task Schedulers

為{幸葍}努か 提交于 2019-12-03 03:38:57
I have a requirement to fire off web service requests to an online api and I thought that Parallel Extensions would be a good fit for my needs. The web service in question is designed to be called repeatedly, but has a mechanism that charges you if you got over a certain number of calls per second. I obviously want to minimize my charges and so was wondering if anyone has seen a TaskScheduler that can cope with the following requirements: Limit the number of tasks scheduled per timespan. I guess if the number of requests exceeded this limit then it would need to throw away the task or possibly

Azure Table Storage Performance from Massively Parallel Threaded Reading

 ̄綄美尐妖づ 提交于 2019-11-30 13:54:08
Short version: Can we read from dozens or hundreds of table partitions in a multi-threaded manner to increase performance by orders of magnitude? Long version: We're working on a system that is storing millions of rows in Azure table storage. We partition the data into small partitions, each one containing about 500 records, which represents a day worth of data for a unit. Since Azure doesn't have a "sum" feature, to pull a year worth of data, we either have to use some pre-caching, or sum the data ourselves in an Azure web or worker role. Assuming the following: - Reading a partition doesn't

Parallel.ForEach not spinning up new threads

爱⌒轻易说出口 提交于 2019-11-29 15:43:39
Parallel.ForEach Not Spinning Up New Threads Hello all, we have a very IO-intensive operation that we wrote using Parallel.ForEach from Microsoft's Parallel Extensions for the .NET Framework. We need to delete a large number of files, and we represent the files to be deleted as a list of lists. Each nested list has 1000 messages in it, and we have 50 of these lists. The issue here is that when I look in the logs afterwards, I only see one thread executing inside of our Parallel.ForEach block. Here's what the code looks like: List<List<Message>> expiredMessagesLists = GetNestedListOfMessages();

Unit testing concurrent software - what do you do?

人走茶凉 提交于 2019-11-29 12:25:00
问题 As software gets more and more concurrent, how do you handle testing the core behaviour of the type with your unit tests (not the parallel behaviour, just the core behaviour)? In the good old days, you had a type, you called it, and you checked either what it returned and/or what other things it called. Nowadays, you call a method and the actual work gets scheduled to run on the next available thread; you don't know when it'll actually start and call the other things - and what's more, those

Throw Exception inside a Task - “await” vs Wait()

こ雲淡風輕ζ 提交于 2019-11-29 05:34:35
static async void Main(string[] args) { Task t = new Task(() => { throw new Exception(); }); try { t.Start(); t.Wait(); } catch (AggregateException e) { // When waiting on the task, an AggregateException is thrown. } try { t.Start(); await t; } catch (Exception e) { // When awating on the task, the exception itself is thrown. // in this case a regular Exception. } } In TPL, When throwing an exception inside a Task, it's wrapped with an AggregateException. But the same is not happening when using the await keyword. What is the explanation for that behavior ? The goal is to make it look/act like

Is CorrelationManager.LogicalOperationStack compatible with Parallel.For, Tasks, Threads, etc

非 Y 不嫁゛ 提交于 2019-11-28 10:09:11
Please see this question for background information: How do Tasks in the Task Parallel Library affect ActivityID? That question asks how Tasks affect Trace.CorrelationManager.ActivityId . @Greg Samson answered his own question with a test program showing that ActivityId is reliable in the context of Tasks. The test program sets an ActivityId at the beginning of the Task delegate, sleeps to simulate work, then checks the ActivityId at the end to make sure that it is the same value (i.e. that it has not been modified by another thread). The program runs successfully. While researching other

Parallel.ForEach not spinning up new threads

强颜欢笑 提交于 2019-11-28 08:56:48
问题 Parallel.ForEach Not Spinning Up New Threads Hello all, we have a very IO-intensive operation that we wrote using Parallel.ForEach from Microsoft's Parallel Extensions for the .NET Framework. We need to delete a large number of files, and we represent the files to be deleted as a list of lists. Each nested list has 1000 messages in it, and we have 50 of these lists. The issue here is that when I look in the logs afterwards, I only see one thread executing inside of our Parallel.ForEach block.

How do Reactive Framework, PLINQ, TPL and Parallel Extensions relate to each other?

百般思念 提交于 2019-11-28 02:46:18
At least since the release of .NET 4.0, Microsoft seems to have put a lot of effort in support for parallel and asynchronous programming and it seems a lot of APIs and libraries around this have emerged. Especially the following fancy names are constantly mentioned everywhere lately: Reactive Framework, PLINQ (Parallel LINQ), TPL (Task Parallel Library) and Parallel Extensions. Now they all seem to be Microsoft products and they all seem to target asynchronous or parallel programming scenarios for .NET. But it is not quite clear what each of them actually is and how they are related to each