Paweł Łukasik Wroc.NET mail: [email protected] Twitter: @pawel_lukasik.
-
Upload
leah-holland -
Category
Documents
-
view
224 -
download
5
Transcript of Paweł Łukasik Wroc.NET mail: [email protected] Twitter: @pawel_lukasik.
![Page 2: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik.](https://reader038.fdocuments.in/reader038/viewer/2022102814/55144ff4550346284e8b509d/html5/thumbnails/2.jpg)
AGENDA
−Po co nam coś nowego?−ThreadPool w .NET 4−Data parallelism−Task parallelism−Nowe klasy
„zsynchronizowane”−Narzędzia
![Page 3: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik.](https://reader038.fdocuments.in/reader038/viewer/2022102814/55144ff4550346284e8b509d/html5/thumbnails/3.jpg)
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.
![Page 4: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik.](https://reader038.fdocuments.in/reader038/viewer/2022102814/55144ff4550346284e8b509d/html5/thumbnails/4.jpg)
ThreadPool – Co nowego?
− Zmiana wewnętrznego działania – mniej blokowania
− Wykradanie zadań (work-stealing)− Szybszy - od 2x (na Dual) do 5,6x (na
Quad)
![Page 5: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik.](https://reader038.fdocuments.in/reader038/viewer/2022102814/55144ff4550346284e8b509d/html5/thumbnails/5.jpg)
Global queue
Thread 1 Thread 2
T1 T2 T3
![Page 6: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik.](https://reader038.fdocuments.in/reader038/viewer/2022102814/55144ff4550346284e8b509d/html5/thumbnails/6.jpg)
DEMO – Data parallelism
![Page 7: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik.](https://reader038.fdocuments.in/reader038/viewer/2022102814/55144ff4550346284e8b509d/html5/thumbnails/7.jpg)
Podsumowanie
− Użycie− ParallelOptions− Anulowanie− Różne strategie wyjścia (tzw. Early
Termination)− Partitioner− Local state
![Page 8: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik.](https://reader038.fdocuments.in/reader038/viewer/2022102814/55144ff4550346284e8b509d/html5/thumbnails/8.jpg)
DEMO - Task parallelism
![Page 9: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik.](https://reader038.fdocuments.in/reader038/viewer/2022102814/55144ff4550346284e8b509d/html5/thumbnails/9.jpg)
TPL - podsumowanie
− Sposób użycia− TaskCreationOptions (PreferFairness,
AttachToParent, LongRunning)− TaskContinuationOptions (NotOn…,
OnlyOn)− Scheduler− Anulowanie
![Page 10: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik.](https://reader038.fdocuments.in/reader038/viewer/2022102814/55144ff4550346284e8b509d/html5/thumbnails/10.jpg)
DEMO - Parallel LINQ
![Page 11: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik.](https://reader038.fdocuments.in/reader038/viewer/2022102814/55144ff4550346284e8b509d/html5/thumbnails/11.jpg)
PLINQ - Podsumowanie
− .AsParallel, ParallelEnumerable− WithDegreeOfParallelism− WithExecutionMode− WithMergeOptions− WithCancellation
![Page 12: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik.](https://reader038.fdocuments.in/reader038/viewer/2022102814/55144ff4550346284e8b509d/html5/thumbnails/12.jpg)
DEMO – Concurrent classes
![Page 13: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik.](https://reader038.fdocuments.in/reader038/viewer/2022102814/55144ff4550346284e8b509d/html5/thumbnails/13.jpg)
Podsumowanie – Concurrent classes− Thread-safe− BlockingCollection− ConcurrentQueue
![Page 14: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik.](https://reader038.fdocuments.in/reader038/viewer/2022102814/55144ff4550346284e8b509d/html5/thumbnails/14.jpg)
DEMO – Debugging tools
![Page 15: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik.](https://reader038.fdocuments.in/reader038/viewer/2022102814/55144ff4550346284e8b509d/html5/thumbnails/15.jpg)
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)
![Page 16: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik.](https://reader038.fdocuments.in/reader038/viewer/2022102814/55144ff4550346284e8b509d/html5/thumbnails/16.jpg)
Pytania?
![Page 17: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik.](https://reader038.fdocuments.in/reader038/viewer/2022102814/55144ff4550346284e8b509d/html5/thumbnails/17.jpg)
Ź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
![Page 18: Paweł Łukasik Wroc.NET mail: lukasik.pawel@gmail.com Twitter: @pawel_lukasik.](https://reader038.fdocuments.in/reader038/viewer/2022102814/55144ff4550346284e8b509d/html5/thumbnails/18.jpg)
Dziękuję za uwagęPytania?