All about Async/Await, System.Threading.Tasks, System.Collections.Concurrent, System.Linq, and more…
The .NET Framework blog published this morning a guest post from yours truly on .NET Memory Allocation Profiling with Visual Studio 2012. As you're trying to improve the performance, throughput, and memory usage of code that uses Tasks, the described profiler in Visual Studio can be a valuable tool in your tool belt (of course, the example I use in that post to highlight the profiler's capabilities is one that uses Task and async/await). I hope you find the post helpful.
In your last year's ForEachAsync with partitions method, how do you determine the # of partitions? Lets say you always want 25 parallel tasks to be run but you don't know the hardware, would you just use the default or pass processor count? Just wondering what questions to ask?
@Jeff: You'd set the number of partitions equal to the maximum number of operations you want to allow to run concurrently. So, if you wanted at most 25 operations to run concurrently, you'd use 25 partitions. Hope that helps.
Thanks Stephen. I've had someone propose a CountdownEvent to set to say 25. How do you choose that over partitioning?
@Jeff: I'm not sure what you're asking. Can you clarify? The forum at social.msdn.microsoft.com/.../threads might also be a better place to ask questions like these, rather than on an unrelated blog post ;)
@Stepehen, done. social.msdn.microsoft.com/.../0af98bb6-9506-4f2c-93df-38d1e9e44718
Hi Stephen, sorry for the off topic question, but regarding performance have you seen this: stackoverflow.com/.../waithandle-waitany-allocates-copy-of-waithandle-everytime-it-is-called
@John: I'm not the authority on that code, but my guess is it's being done to avoid complications that could occur if the passed in array were mutated concurrently to its being used. It validates the data as it copied to the internal array, which the caller doesn't have access to, so after validation the caller can't erroneously or maliciously change one of the values in the array to avoid validation.
Off-topic: could you pls look at this problem - related to returning values from a parent task?
@Pravin: The answers on the stack overflow post already explain what's going on. This is not a bug in TPL.
Could you please answer this question: social.msdn.microsoft.com/.../40e82596-a94a-48cd-b2ff-abc29f6d8d7e
I asked it on stackoverflow too but silence was the answer.
Is there possibility that task.StartNew() returns a null.
@Savil: No, that should not happen with the built-in StartNew methods.
I have just watched your presentations on Build about async and I'm really impressed by how fast you touch type. Can you give me hint how to get even closer to this? I'm a noob touch typist by the way :).
@Ivan: Thanks :) I spent a lot of time years ago with various software packages that taught and honed touch typing skills. I haven't used one in years, but I'm sure they still exist in some fashion.
Thanks I've already found some. Can you tell me which fingers in what sequence do you use to type something like this