Peter Csala
2 Agenda • Definitions & Terminologies • Problems & Toolbox • Demos
Definitions and Terminologies
4 Concepts & Misconceptions Parallel Programming Concurrent Programming Asyncronous Programming Multi-Threaded Programming
5 Prog. model: Sync vs Async
6 Execution: Parallel vs Concurrent
7 Environment: Single vs Multi Threading
8 Rumor: Zen 3 can run 4 threads / core
9 Rumor: Ryzen ThreadRipper (64cores)
10 Types: Data vs Task
Problems & Tools
12 Problems: Shared State
13 Toolbox against concurrent mutation • Syncronization Primitives • Concurrent Collections • Immutable state
14 Patterns against concurrent mutation • Fork / Join • Master – Worker • Producer + Consumer • Divide & Conquer • MapReduce • Observer • Pipeline • All To All • Stencil • Etc.
15 It’s all about isolation
Enough theory, Let’s practice
17 The Downloader Functional Req.s • I want to be able to download arbitrary number of web contents • I want to be able to process them in arbitrary way • It MUST be blazingly fast • It MUST be superb easy to use • Why is this not done yet? Non-Functional Req.s • Ensure that the provided strings are valid Uris • Ensure post-processing ability via continuation / callback • It should run in parallel without exhausting all resources • Interface should ask for only the bear minimum (use default params)
18 Architecture: Cardinality
19 Architecture: Cardinality
20 Architecture: Cardinality
21 Architecture: Cardinality
22 Architecture: Throttling
23 Architecture: Shared State • The whole source is shared • The source is pre-partitioned • The partitions are processed separately by pulling
24 Architecture: Shared State • The source is pre-partitioned • The partitions are not shared • The partitions are processed separately by iterating
25 Architecture: Shared State • The whole source is shared • The source is dynamically partitioned • The source pushes the data to the targets
26 It’s demo time
27 What have we learnt?
28 What have we learnt? • (Non-)deterministic • Slow down • Over parallelisation • Partitioning is hard • Common pitfalls • Measure base line • Measure speed-up • CPU vs I/O bound • Immutables • Enormous toolset
29 Where should I look for details? • Parallel class • PLINQ partitioning • Channels • Parallel data structure, 2 • Synchronization primitives, 2 • Compare Parallel models • Immutable Collections, 2 • Throttling • Potential Pitfalls, PLINQ • Async Guidance • Async antipatterns • Avoid sync problem • VS Threading nuget • Concurrency Visualizer
30 Is there any free e-book? • Patterns & Practices Parallel Programming with Microsoft .NET • Patterns of Parallel Programming • Introduction of TPL Dataflow • Parallel Extension Extras
31 Is there any good book?
Parallel programming in .NET

Parallel programming in .NET

Editor's Notes

  • #5 https://medium.com/swift-india/concurrency-parallelism-threads-processes-async-and-sync-related-39fd951bc61d
  • #6 http://www.enterpriseintegrationpatterns.com/patterns/messaging/Introduction.html
  • #7 https://www.raywenderlich.com/60749/grand-central-dispatch-in-depth-part-1
  • #8 https://www.cs.uic.edu/~jbell/CourseNotes/OperatingSystems/4_Threads.html
  • #9 https://www.tweaktown.com/news/67801/amds-next-gen-zen-3-rumor-4-threads-per-core-enables-64c-256t-chips/index.html
  • #10 https://wccftech.com/amd-ryzen-threadripper-3960x-24-core-48-thread-7nm-zen-2-cpu-confirmed/
  • #11 http://help.pervasive.com/display/DR62/General+Concepts
  • #15 https://onlinelibrary.wiley.com/doi/full/10.1002/cpe.4175 http://snir.cs.illinois.edu/patterns/patterns.pdf