Is it faster?

2011/12/11

no comments

Is it faster?

does the .NET 4.5 really run faster than 4?

Tpl, task, await, async, performance

this post will summaries TPL Performance Improvements in .NET 4.5.

the TPL team has put lot of effort to dramatically improve the overall performance of .NET 4.5.

the improvement was achieve both by execution and memory allocation optimization.

in result .NET 4.5 parallelism is faster and more GC friendly.

allocation optimization does improve the overall execution speedup, because GC collection does have significantly impact on the overall performance (thread freezing and more).

the benchmarks in this post were execute against 100000 tasks with 25 iterations.

Continuation:

.NET 4.5 acknowledged the continuation-style of programming to be a mainline scenario (async/await support). lot of effort were put into making continuations faster.

using the magical Interlocked.CompareExchange the continuation footprint were reduce while the task is having single continuation (there will be no continuation list assignment in this case), but even when having more than a single continuation .NET 4.5 is still faster than in .NET 4.

the following benchmark show single continuation assignment:

performance (speedup):

Tpl, task, await, async

memory allocation:

Tpl, task, await, async

the following benchmark show multiple continuation assignment:

performance (speedup):

Tpl, task, await, async

memory allocation:

Tpl, task, await, async

 
Restructuring Task:

the task internal was redesign to have a minimal memory footprint for common scenarios, while also supporting more rare scenarios.

the following benchmark show improvement over Task creation:

performance (speedup):

image

memory allocation:

image

 

the following benchmark show improvement over creation of Task<T>:

performance (speedup):

image

memory allocation:

image

 
TaskCompletionSource

the following benchmark show improvement over creation of TaskCompletionSource:

performance (speedup):

Tpl, task, await, async

memory allocation:

Tpl, task, await, async

 

summary

TPL 4.5 performance was significantly improved both in terms of speedup and allocations.

you can see the full benchmarks information and more details about the inner stuff at TPL Performance Improvements in .Net 4.5 by Joseph E. Hoag.

Shout it kick it on DotNetKicks.com

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>