paweł Łukasik wroc.net mail: [email protected] twitter: @pawel_lukasik
TRANSCRIPT
AGENDA
−Po co nam coś nowego?−ThreadPool w .NET 4−Data parallelism−Task parallelism−Nowe klasy
„zsynchronizowane”−Narzędzia
Po co nam coś nowego?
− Abstrakcja− Spójne API− Uproszczone użycie− Dynamiczne zrównoleglenie− Anulowanie zadań− Stany wątków
A wszystko to tylko w jednym celu….
The purpose of the TPL is to make developers more productive by simplifying the process of adding parallelism and concurrency to applications. The TPL scales the degree of concurrency dynamically to most efficiently use all the processors that are available. In addition, the TPL handles the partitioning of the work, the scheduling of threads on the ThreadPool, cancellation support, state management, and other low-level details. By using TPL, you can maximize the performance of your code while focusing on the work that your program is designed to accomplish.
ThreadPool – Co nowego?
− Zmiana wewnętrznego działania – mniej blokowania
− Wykradanie zadań (work-stealing)− Szybszy - od 2x (na Dual) do 5,6x (na
Quad)
Global queue
Thread 1 Thread 2
T1 T2 T3
DEMO – Data parallelism
Podsumowanie
− Użycie− ParallelOptions− Anulowanie− Różne strategie wyjścia (tzw. Early
Termination)− Partitioner− Local state
DEMO - Task parallelism
TPL - podsumowanie
− Sposób użycia− TaskCreationOptions (PreferFairness,
AttachToParent, LongRunning)− TaskContinuationOptions (NotOn…,
OnlyOn)− Scheduler− Anulowanie
DEMO - Parallel LINQ
PLINQ - Podsumowanie
− .AsParallel, ParallelEnumerable− WithDegreeOfParallelism− WithExecutionMode− WithMergeOptions− WithCancellation
DEMO – Concurrent classes
Podsumowanie – Concurrent classes− Thread-safe− BlockingCollection− ConcurrentQueue
DEMO – Debugging tools
Debugging Tools - Podsumowanie
− Pozwalają w łatwiejszy sposób przyjrzeć się naszej aplikacji− Śledzenie tasków (Parallel Tasks)− Obrazowanie zależności (Parallel Stacks)− Wydajność (Performance Analysis)
Pytania?
Źródła
− http://msdn.microsoft.com/en-gb/concurrency/default.aspx
− http://blogs.msdn.com/pfxteam/default.aspx
− http://code.msdn.microsoft.com/ParExtSamples
− http://blogs.msdn.com/pfxteam/archive/2010/04/21/9997559.aspx
− Axum - http://msdn.microsoft.com/en-us/devlabs/dd795202.aspx
Dziękuję za uwagęPytania?