parallel-extensions

Can Parallel.ForEach be used safely with CloudTableQuery

蹲街弑〆低调 提交于 2020-01-17 01:36:08
问题 I have a reasonable number of records in an Azure Table that I'm attempting to do some one time data encryption on. I thought that I could speed things up by using a Parallel.ForEach . Also because there are more than 1K records and I don't want to mess around with continuation tokens myself I'm using a CloudTableQuery to get my enumerator. My problem is that some of my records have been double encrypted and I realised that I'm not sure how thread safe the enumerator returned by

Unexpected segfault with __gnu_parallel::accumulate

家住魔仙堡 提交于 2020-01-16 00:51:06
问题 This is really confusing me, I would appreciate if anyone could help me out. (EDIT: thought it was a templated problem, I was mistaken with this) I want to add multiple copies of the following class with gnu's parallelised accumulate algorithm (stored in #include <parallel/numeric> ) The class deliberately doesn't do much, I don't think this is a thread collision problem? template<class T> class NaturalParameters { public: typedef typename std::vector<T>::iterator iterator; NaturalParameters(

TransactionScope not working with Parallel Extensions?

夙愿已清 提交于 2020-01-11 05:14:46
问题 If i do the following: Using scope = New TransactionScope() entries.Content.ReadAs(Of IList(Of WebMaint)).AsParallel.ForAll(Sub(entry) _repos.Update(entry) End Sub) scope.Complete() End Using TransactionScope doesn't work. If i put a breakpoint on the scope.complete no transaction is active and the updates are already complete. If i change it to: Using scope = New TransactionScope() entries.Content.ReadAs(Of IList(Of WebMaint)).ToList().ForEach(Sub(entry) _repos.Update(entry) End Sub) scope

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

℡╲_俬逩灬. 提交于 2019-12-29 06:41:11
问题 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

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

南楼画角 提交于 2019-12-29 06:41:02
问题 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

PLINQ query, need to know how many iterations performed

时光总嘲笑我的痴心妄想 提交于 2019-12-25 05:18:28
问题 what I'm basically doing is iterating in parallel over a sequence of letter combinations, when I get the combo I want it's considered a win. I want to get all the wins from this query (which it's doing correctly), but the trick has been how to keep track of the number of times the test for a win was executed (basically the method that returns true/false that it won). I'm creating an instance variable in the class that increments each time the test on the combo is performed, but each time I

Parallel Brute-Force Algorithm

一曲冷凌霜 提交于 2019-12-21 22:39:28
问题 So I was looking at http://codahale.com/how-to-safely-store-a-password/# and became curious how fast different hash could be bruteforced on a somewhat powerful desktop computer and was tempted to test it Most of the algorithms I've seen though are single-threaded and it struck me that this would be a really interesting challenge in using c# 4.0 Parallel.net/Plinq extensions and concurrent structures (like ConcurrentBag and IProducerConsumer). So my task is as follows, build the most efficient

Task Parallel Library - Custom Task Schedulers

☆樱花仙子☆ 提交于 2019-12-20 14:42:19
问题 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

Azure Table Storage Performance from Massively Parallel Threaded Reading

心不动则不痛 提交于 2019-12-18 15:52:46
问题 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

Parallel.ForEach keeps spawning new threads

跟風遠走 提交于 2019-12-17 15:57:39
问题 While I was using Parallel.ForEach in my program, I found that some threads never seemed to finish. In fact, it kept spawning new threads over and over, a behaviour that I wasn't expecting and definitely don't want. I was able to reproduce this behaviour with the following code which, just like my 'real' program, both uses processor and memory a lot (.NET 4.0 code): public class Node { public Node Previous { get; private set; } public Node(Node previous) { Previous = previous; } } public