The Free Lunch is Over

Post on 22-Feb-2016

44 views 0 download

Tags:

description

The Free Lunch is Over. Getting good at Parallel with .NET 4.0. jtwist@microsoft.com. www.thejoyofcode.com. @ joshtwist. But first…. You could have been at the PDC!. An apology …. The Free Lunch is Over. - PowerPoint PPT Presentation

transcript

The Free Lunch is Over

Getting good at Parallel with .NET 4.0

www.thejoyofcode.com@joshtwist

jtwist@microsoft.com

But first…• An apology…

You could

have been

at the PDC!

The Free Lunch is OverPublished in March 2005

…the big theme of the 2004 In-Stat/MDR Fall

Processor Forum was multicore devices, as many

companies showed new or updated multicore

processors. Looking back, it’s not much of a

stretch to call 2004 the year of multicore.

http://www.gotw.ca/publications/concurrency-ddj.htm

10,000,000

1,000,000

100,000

10,000

1,000

100

10

1

01970 1975 1980 1985 1990 1995 2000 2005 2010

Moore’s Law

Clock Speed (MHz)

Transistors (000s)

The free lunch ended in 2005; why am I still eating?

Web ServersMany concurrent

requests

Batch ProcessingVirtualisation

DesktopsLow Hanging Fruit

Many Processes To Run

But soon…

PFX team in Redmond – 128

cores!Our labs – 24 coresNew desktops – 8

cores Me – 2 cores

The Free Lunch is Over

Concurrency is the next major revolution in how

we write software…

… The vast majority of programmers today don’t

grok concurrency, just as the vast majority of

programmers 15 years ago didn’t yet grok objects

http://www.gotw.ca/publications/concurrency-ddj.htm

Why? Tools for concurrency before .Net 4

• APM (Asynchronous Programming Model)• EAP (Event-based Asynchronous Programming)• new Thread()• ThreadPool & QueueUserWorkItem• Sync Primitives: ResetEvents,

Semaphores, WaitHandles, Monitors, Slims etc.

• ThreadStatic & CallContext

Two challenges

1. Logically rethink the processing in your application to support concurrency – tough!

2. Rewrite the application using these basic primitives – tough!

In .Net 4• Parallel Extensions– Tasks– Parallel – PLINQ– ThreadLocal / Lazy– Visual Studio 2010 Concurrency

Debugging Support

Two primary types

Task Parallelism Data Parallelism

Task Parallelism

New Credit Application

Store Request

Validate Address

Get Credit References

Get Internal Credit Data

Decide!

DEMONSTRATIONTask Parallelism

Two primary types

Data Parallelism

DEMONSTRATIONData Parallelism

Some things not covered• BlockingCollections and Pipelines• FromSynchronizationContext• Visual Studio Debugging Tools• and much more…

Q&A• 1. Your questions?

• 2. My go!

My questions• Who uses WF (Workflow)?• Version 4?• Those who don’t – why not?• Those who do…–What are your impressions?– Any feedback?

Thank you!

www.thejoyofcode.com@joshtwist

jtwist@microsoft.com

Want help from people like me? Ask about PSfD.

Questions also accepted by

Twitter. Follow me or else.