In this presentation we go through the parallel programming posibilities in .NET C#.
First we discuss some core concepts then we explore the problem space and the related toolbox.
Finally we will have a sample library which implements the same interface in 20+ different ways to show you the alternatives.
Related code can be reached here: https://github.com/peter-csala/parallel-programming-dotnet
17. 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)
23. 23
Architecture: Shared State
• The whole source is shared
• The source is pre-partitioned
• The partitions are processed
separately by pulling
24. 24
Architecture: Shared State
• The source is pre-partitioned
• The partitions are not shared
• The partitions are processed
separately by iterating
25. 25
Architecture: Shared State
• The whole source is shared
• The source is dynamically
partitioned
• The source pushes the data to the
targets
28. 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. 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. 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