SlideShare a Scribd company logo
1 of 25
Parallel Extensions in .Net 4.0 Dmytro Maleev for Lviv.Net User Group
Agenda Куда катится мир? Hello, Parallel Extensions! Parallel vs Multithreading Parallel Loops Tasks PLINQ CDS & Thread Enchantments References Q&A
Куда катится мир Forget about CPU frequency increase! There are a lot of issues with this, which will be fixed in future! 1998  Intel 80486 80Mhz 1 Core 2007 Core 2 Duo 2.13 GHz 2 Core 2000 Celeron 400Mhz 1 Core 2010 Intel i5 3.3GHz 2 Core 4 Threads 2003 Athlon XP 1.6+GHz 1 Core ?
Куда катится мир For now…ENLARGE YOUR… CPU CORE COUNT! PEN PEN
Hello, Parallel Extensions! Parallel Extensions, previously known as the Parallel Framework Extensions or PFX, is a managed concurrency library being developed by a collaboration between Microsoft Research and the CLR team at Microsoft. It is composed of two parts: Parallel LINQ (PLINQ) andTask Parallel Library (TPL).It also consists of a set of coordination data structures (CDS) – sets of data structures used to synchronize and co-ordinate the execution of concurrent tasks.Thelibrary was released as a CTP on November 29, 2007and refreshed again in December 2007 and June 2008. Microsoft has announced that the Parallel Extensions to .NET will release as part of the .NET 4.0 Framework release. ©Wikipedia
Hello, Parallel Extensions! Visual Studio Debugging and profiling support Parallel Extensions PLINQ Task Parallel Library Task Scheduler CDS
Parallel vs Multithreading Multithreaded!=parallelization “ If on a single core machine you are using threads and it makes perfect sense for your scenario, then you are not "doing parallelism", you are just doing multithreading” ”On a single core you can use threads and you can have concurrency, but to achieve parallelism on a multi-core box you have to identify in your code the exploitable concurrency: the portions of your code that can truly run at the same time.” Daniel Moth
Parallel vs Multithreading
Dark Side of Paprallelization and Multithreading Race conditions http://en.wikipedia.org/wiki/Race_condition 2.	Deadlocks http://en.wikipedia.org/wiki/Deadlock http://en.wikipedia.org/wiki/Dining_philosophers_problem Thread starvation Difficult to code and debug Environmental
Народная мудрость!
Parallel Loops Parallel.For() Parallel.For(0, 100, i =>             {                 Console.WriteLine("This is I-I-I-I-I-I: {0}", i);             }); Parallel.ForEach() Parallel.ForEach(ThisIsCollection, collectionItem => { collectionItem.Hello(); }); Parallel Options Parallel.Invoke()
Parallel Loops. Use Force wisely! Parallelization Can Hurt Performance http://msdn.microsoft.com/en-us/library/dd560853(VS.100).aspx http://en.wikipedia.org/wiki/Context_switch
DEMO AntiSocialRobots
Task - Task Scheduler Task is a new class that represents the work you want completed. There are methods to create,  schedule, and synchronize tasks in your application. Tasks are controlled by task scheduler. Tasks scheduler works with thread pool.
Task In Deep Tasks can: Task can be created Task can wait! Task can simply Wait(), WaitAll() or WaitAny(). Task knows when it is completed ( IsCompleted property) Task can ContinueWith() Task can return value Task has Options and Status
Demo Strassen algorithm
PLINQ PLINQ is just parallelized version of LINQ Not parallelized: LINQ-to-SQL & LINQ-to-Entity. LINQ: var query = from s in someCollection let result = CoolService.CallService(s) select result; PLINQ: varquery = from s in someCollection.AsParallel() let result = CoolService.CallService(s) select result;
PLINQ. How it works?
PLINQ. Overview	 Ordering Results AsOrdered() ForAll Operator() AsSequential() WithMergeOptions Parallel Performance Analyzer. Just for rich
DEMO	 Baby Names
CDS & Thread Enchantments Thread Enchantments: Thread.Yield() Monitor.Enter() Concurrent Collections ConcurrentStack (LIFO) ConcurrentQueue (FIFO) ConcurrentDictionary ConcurrentBag BlockingCollection
Synchronization Primitives Barrier “Let’s meet near monument and then go to have a beer” Cancellation Tokens CountDownEvent ManualResetEventSlim and SemaphoreSlim SpinLock ThreadLocal<T>
References	 Parallel Programming with .NET http://blogs.msdn.com/b/pfxteam/ Wiki http://en.wikipedia.org/wiki/Parallel_Extensions Introducing .NET 4.0 http://www.amazon.com/Introducing-NET-4-0-Visual-Experts/dp/143022455X Lviv.Net User Group http://dotnetug-lviv.blogspot.com/
Q&A ?
If you still have a questions	 Mail me: diwingless@gmail.com Skype me: hmmidma Twitter: dimko1

More Related Content

Similar to Parallel extensions in .Net 4.0

MTaulty_DevWeek_Parallel
MTaulty_DevWeek_ParallelMTaulty_DevWeek_Parallel
MTaulty_DevWeek_Parallelukdpe
 
Parallel Extentions to the .NET Framework
Parallel Extentions to the .NET FrameworkParallel Extentions to the .NET Framework
Parallel Extentions to the .NET Frameworkukdpe
 
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go WrongJDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go WrongPROIDEA
 
Here comes the Loom - Ya!vaConf.pdf
Here comes the Loom - Ya!vaConf.pdfHere comes the Loom - Ya!vaConf.pdf
Here comes the Loom - Ya!vaConf.pdfKrystian Zybała
 
Parallel Computing For Managed Developers
Parallel Computing For Managed DevelopersParallel Computing For Managed Developers
Parallel Computing For Managed DevelopersBala Subra
 
Getting started with Clojure
Getting started with ClojureGetting started with Clojure
Getting started with ClojureJohn Stevenson
 
ABRIDGED VERSION - Joys & frustrations of putting 34,000 lines of Haskell in...
 ABRIDGED VERSION - Joys & frustrations of putting 34,000 lines of Haskell in... ABRIDGED VERSION - Joys & frustrations of putting 34,000 lines of Haskell in...
ABRIDGED VERSION - Joys & frustrations of putting 34,000 lines of Haskell in...Saurabh Nanda
 
DotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NETDotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NETMaarten Balliauw
 
Oscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simpleOscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simpleMartin Odersky
 
Exploring .NET memory management - JetBrains webinar
Exploring .NET memory management - JetBrains webinarExploring .NET memory management - JetBrains webinar
Exploring .NET memory management - JetBrains webinarMaarten Balliauw
 
Using spl tools in your code
Using spl tools in your codeUsing spl tools in your code
Using spl tools in your codeElizabeth Smith
 
Thinking in parallel ab tuladev
Thinking in parallel ab tuladevThinking in parallel ab tuladev
Thinking in parallel ab tuladevPavel Tsukanov
 
Optimizing Application Architecture (.NET/Java topics)
Optimizing Application Architecture (.NET/Java topics)Optimizing Application Architecture (.NET/Java topics)
Optimizing Application Architecture (.NET/Java topics)Ravi Okade
 
Sparklife - Life In The Trenches With Spark
Sparklife - Life In The Trenches With SparkSparklife - Life In The Trenches With Spark
Sparklife - Life In The Trenches With SparkIan Pointer
 
Parallel Programming: Beyond the Critical Section
Parallel Programming: Beyond the Critical SectionParallel Programming: Beyond the Critical Section
Parallel Programming: Beyond the Critical SectionTony Albrecht
 
SQL Server In-Memory OLTP introduction (Hekaton)
SQL Server In-Memory OLTP introduction (Hekaton)SQL Server In-Memory OLTP introduction (Hekaton)
SQL Server In-Memory OLTP introduction (Hekaton)Shy Engelberg
 
Hadoop Performance Optimization at Scale, Lessons Learned at Twitter
Hadoop Performance Optimization at Scale, Lessons Learned at TwitterHadoop Performance Optimization at Scale, Lessons Learned at Twitter
Hadoop Performance Optimization at Scale, Lessons Learned at TwitterDataWorks Summit
 
Gpu and The Brick Wall
Gpu and The Brick WallGpu and The Brick Wall
Gpu and The Brick Wallugur candan
 

Similar to Parallel extensions in .Net 4.0 (20)

MTaulty_DevWeek_Parallel
MTaulty_DevWeek_ParallelMTaulty_DevWeek_Parallel
MTaulty_DevWeek_Parallel
 
Parallel Extentions to the .NET Framework
Parallel Extentions to the .NET FrameworkParallel Extentions to the .NET Framework
Parallel Extentions to the .NET Framework
 
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go WrongJDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
JDD 2016 - Grzegorz Rozniecki - Java 8 What Could Possibly Go Wrong
 
Here comes the Loom - Ya!vaConf.pdf
Here comes the Loom - Ya!vaConf.pdfHere comes the Loom - Ya!vaConf.pdf
Here comes the Loom - Ya!vaConf.pdf
 
Clustering van IT-componenten
Clustering van IT-componentenClustering van IT-componenten
Clustering van IT-componenten
 
Parallel Computing For Managed Developers
Parallel Computing For Managed DevelopersParallel Computing For Managed Developers
Parallel Computing For Managed Developers
 
Devoxx
DevoxxDevoxx
Devoxx
 
Getting started with Clojure
Getting started with ClojureGetting started with Clojure
Getting started with Clojure
 
ABRIDGED VERSION - Joys & frustrations of putting 34,000 lines of Haskell in...
 ABRIDGED VERSION - Joys & frustrations of putting 34,000 lines of Haskell in... ABRIDGED VERSION - Joys & frustrations of putting 34,000 lines of Haskell in...
ABRIDGED VERSION - Joys & frustrations of putting 34,000 lines of Haskell in...
 
DotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NETDotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NET
 
Oscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simpleOscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simple
 
Exploring .NET memory management - JetBrains webinar
Exploring .NET memory management - JetBrains webinarExploring .NET memory management - JetBrains webinar
Exploring .NET memory management - JetBrains webinar
 
Using spl tools in your code
Using spl tools in your codeUsing spl tools in your code
Using spl tools in your code
 
Thinking in parallel ab tuladev
Thinking in parallel ab tuladevThinking in parallel ab tuladev
Thinking in parallel ab tuladev
 
Optimizing Application Architecture (.NET/Java topics)
Optimizing Application Architecture (.NET/Java topics)Optimizing Application Architecture (.NET/Java topics)
Optimizing Application Architecture (.NET/Java topics)
 
Sparklife - Life In The Trenches With Spark
Sparklife - Life In The Trenches With SparkSparklife - Life In The Trenches With Spark
Sparklife - Life In The Trenches With Spark
 
Parallel Programming: Beyond the Critical Section
Parallel Programming: Beyond the Critical SectionParallel Programming: Beyond the Critical Section
Parallel Programming: Beyond the Critical Section
 
SQL Server In-Memory OLTP introduction (Hekaton)
SQL Server In-Memory OLTP introduction (Hekaton)SQL Server In-Memory OLTP introduction (Hekaton)
SQL Server In-Memory OLTP introduction (Hekaton)
 
Hadoop Performance Optimization at Scale, Lessons Learned at Twitter
Hadoop Performance Optimization at Scale, Lessons Learned at TwitterHadoop Performance Optimization at Scale, Lessons Learned at Twitter
Hadoop Performance Optimization at Scale, Lessons Learned at Twitter
 
Gpu and The Brick Wall
Gpu and The Brick WallGpu and The Brick Wall
Gpu and The Brick Wall
 

More from Dima Maleev

JavaScript in Mobile Development
JavaScript in Mobile DevelopmentJavaScript in Mobile Development
JavaScript in Mobile DevelopmentDima Maleev
 
What is new in Angular 2.0
What is new in Angular 2.0What is new in Angular 2.0
What is new in Angular 2.0Dima Maleev
 
Fear and Loathing at PhoneGap
Fear and Loathing at PhoneGapFear and Loathing at PhoneGap
Fear and Loathing at PhoneGapDima Maleev
 
Development Applications for Chrome OS
Development Applications for Chrome OSDevelopment Applications for Chrome OS
Development Applications for Chrome OSDima Maleev
 
Mobile for JS Developer
Mobile for JS DeveloperMobile for JS Developer
Mobile for JS DeveloperDima Maleev
 
Development Application for Windows 8 by Eugene Kiriyan
Development Application for Windows 8 by Eugene KiriyanDevelopment Application for Windows 8 by Eugene Kiriyan
Development Application for Windows 8 by Eugene KiriyanDima Maleev
 
.NET MicroFramework by Yulian Slobodyan
.NET MicroFramework by Yulian Slobodyan.NET MicroFramework by Yulian Slobodyan
.NET MicroFramework by Yulian SlobodyanDima Maleev
 
Modern mobile development overview
Modern mobile development overviewModern mobile development overview
Modern mobile development overviewDima Maleev
 
Go mobile with Windows Phone
Go mobile with Windows PhoneGo mobile with Windows Phone
Go mobile with Windows PhoneDima Maleev
 
Lviv .Net User Group. NHibernate
Lviv .Net User Group. NHibernateLviv .Net User Group. NHibernate
Lviv .Net User Group. NHibernateDima Maleev
 
Time. To manage, or not to manage
Time. To manage, or not to manageTime. To manage, or not to manage
Time. To manage, or not to manageDima Maleev
 
Создание SharePoint 2010 решений в Visual Studio
Создание SharePoint 2010 решений в Visual StudioСоздание SharePoint 2010 решений в Visual Studio
Создание SharePoint 2010 решений в Visual StudioDima Maleev
 
24000 Days Of UX
24000 Days Of UX24000 Days Of UX
24000 Days Of UXDima Maleev
 
Developing silverlight applications for windows phone 7 series
Developing silverlight applications for windows phone 7 seriesDeveloping silverlight applications for windows phone 7 series
Developing silverlight applications for windows phone 7 seriesDima Maleev
 
New Features Of ASP.Net 4 0
New Features Of ASP.Net 4 0New Features Of ASP.Net 4 0
New Features Of ASP.Net 4 0Dima Maleev
 

More from Dima Maleev (17)

Mems
MemsMems
Mems
 
JavaScript in Mobile Development
JavaScript in Mobile DevelopmentJavaScript in Mobile Development
JavaScript in Mobile Development
 
What is new in Angular 2.0
What is new in Angular 2.0What is new in Angular 2.0
What is new in Angular 2.0
 
Fear and Loathing at PhoneGap
Fear and Loathing at PhoneGapFear and Loathing at PhoneGap
Fear and Loathing at PhoneGap
 
Development Applications for Chrome OS
Development Applications for Chrome OSDevelopment Applications for Chrome OS
Development Applications for Chrome OS
 
Mobile for JS Developer
Mobile for JS DeveloperMobile for JS Developer
Mobile for JS Developer
 
Gamification
GamificationGamification
Gamification
 
Development Application for Windows 8 by Eugene Kiriyan
Development Application for Windows 8 by Eugene KiriyanDevelopment Application for Windows 8 by Eugene Kiriyan
Development Application for Windows 8 by Eugene Kiriyan
 
.NET MicroFramework by Yulian Slobodyan
.NET MicroFramework by Yulian Slobodyan.NET MicroFramework by Yulian Slobodyan
.NET MicroFramework by Yulian Slobodyan
 
Modern mobile development overview
Modern mobile development overviewModern mobile development overview
Modern mobile development overview
 
Go mobile with Windows Phone
Go mobile with Windows PhoneGo mobile with Windows Phone
Go mobile with Windows Phone
 
Lviv .Net User Group. NHibernate
Lviv .Net User Group. NHibernateLviv .Net User Group. NHibernate
Lviv .Net User Group. NHibernate
 
Time. To manage, or not to manage
Time. To manage, or not to manageTime. To manage, or not to manage
Time. To manage, or not to manage
 
Создание SharePoint 2010 решений в Visual Studio
Создание SharePoint 2010 решений в Visual StudioСоздание SharePoint 2010 решений в Visual Studio
Создание SharePoint 2010 решений в Visual Studio
 
24000 Days Of UX
24000 Days Of UX24000 Days Of UX
24000 Days Of UX
 
Developing silverlight applications for windows phone 7 series
Developing silverlight applications for windows phone 7 seriesDeveloping silverlight applications for windows phone 7 series
Developing silverlight applications for windows phone 7 series
 
New Features Of ASP.Net 4 0
New Features Of ASP.Net 4 0New Features Of ASP.Net 4 0
New Features Of ASP.Net 4 0
 

Recently uploaded

ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxPoojaSen20
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 

Recently uploaded (20)

ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 

Parallel extensions in .Net 4.0

  • 1. Parallel Extensions in .Net 4.0 Dmytro Maleev for Lviv.Net User Group
  • 2. Agenda Куда катится мир? Hello, Parallel Extensions! Parallel vs Multithreading Parallel Loops Tasks PLINQ CDS & Thread Enchantments References Q&A
  • 3. Куда катится мир Forget about CPU frequency increase! There are a lot of issues with this, which will be fixed in future! 1998 Intel 80486 80Mhz 1 Core 2007 Core 2 Duo 2.13 GHz 2 Core 2000 Celeron 400Mhz 1 Core 2010 Intel i5 3.3GHz 2 Core 4 Threads 2003 Athlon XP 1.6+GHz 1 Core ?
  • 4. Куда катится мир For now…ENLARGE YOUR… CPU CORE COUNT! PEN PEN
  • 5. Hello, Parallel Extensions! Parallel Extensions, previously known as the Parallel Framework Extensions or PFX, is a managed concurrency library being developed by a collaboration between Microsoft Research and the CLR team at Microsoft. It is composed of two parts: Parallel LINQ (PLINQ) andTask Parallel Library (TPL).It also consists of a set of coordination data structures (CDS) – sets of data structures used to synchronize and co-ordinate the execution of concurrent tasks.Thelibrary was released as a CTP on November 29, 2007and refreshed again in December 2007 and June 2008. Microsoft has announced that the Parallel Extensions to .NET will release as part of the .NET 4.0 Framework release. ©Wikipedia
  • 6. Hello, Parallel Extensions! Visual Studio Debugging and profiling support Parallel Extensions PLINQ Task Parallel Library Task Scheduler CDS
  • 7. Parallel vs Multithreading Multithreaded!=parallelization “ If on a single core machine you are using threads and it makes perfect sense for your scenario, then you are not "doing parallelism", you are just doing multithreading” ”On a single core you can use threads and you can have concurrency, but to achieve parallelism on a multi-core box you have to identify in your code the exploitable concurrency: the portions of your code that can truly run at the same time.” Daniel Moth
  • 9. Dark Side of Paprallelization and Multithreading Race conditions http://en.wikipedia.org/wiki/Race_condition 2. Deadlocks http://en.wikipedia.org/wiki/Deadlock http://en.wikipedia.org/wiki/Dining_philosophers_problem Thread starvation Difficult to code and debug Environmental
  • 11. Parallel Loops Parallel.For() Parallel.For(0, 100, i => { Console.WriteLine("This is I-I-I-I-I-I: {0}", i); }); Parallel.ForEach() Parallel.ForEach(ThisIsCollection, collectionItem => { collectionItem.Hello(); }); Parallel Options Parallel.Invoke()
  • 12. Parallel Loops. Use Force wisely! Parallelization Can Hurt Performance http://msdn.microsoft.com/en-us/library/dd560853(VS.100).aspx http://en.wikipedia.org/wiki/Context_switch
  • 14. Task - Task Scheduler Task is a new class that represents the work you want completed. There are methods to create, schedule, and synchronize tasks in your application. Tasks are controlled by task scheduler. Tasks scheduler works with thread pool.
  • 15. Task In Deep Tasks can: Task can be created Task can wait! Task can simply Wait(), WaitAll() or WaitAny(). Task knows when it is completed ( IsCompleted property) Task can ContinueWith() Task can return value Task has Options and Status
  • 17. PLINQ PLINQ is just parallelized version of LINQ Not parallelized: LINQ-to-SQL & LINQ-to-Entity. LINQ: var query = from s in someCollection let result = CoolService.CallService(s) select result; PLINQ: varquery = from s in someCollection.AsParallel() let result = CoolService.CallService(s) select result;
  • 18. PLINQ. How it works?
  • 19. PLINQ. Overview Ordering Results AsOrdered() ForAll Operator() AsSequential() WithMergeOptions Parallel Performance Analyzer. Just for rich
  • 21. CDS & Thread Enchantments Thread Enchantments: Thread.Yield() Monitor.Enter() Concurrent Collections ConcurrentStack (LIFO) ConcurrentQueue (FIFO) ConcurrentDictionary ConcurrentBag BlockingCollection
  • 22. Synchronization Primitives Barrier “Let’s meet near monument and then go to have a beer” Cancellation Tokens CountDownEvent ManualResetEventSlim and SemaphoreSlim SpinLock ThreadLocal<T>
  • 23. References Parallel Programming with .NET http://blogs.msdn.com/b/pfxteam/ Wiki http://en.wikipedia.org/wiki/Parallel_Extensions Introducing .NET 4.0 http://www.amazon.com/Introducing-NET-4-0-Visual-Experts/dp/143022455X Lviv.Net User Group http://dotnetug-lviv.blogspot.com/
  • 24. Q&A ?
  • 25. If you still have a questions Mail me: diwingless@gmail.com Skype me: hmmidma Twitter: dimko1