SlideShare a Scribd company logo
1 of 29
Download to read offline
SCALING UP

1
WHAT YOU WILL
LEARN TODAY
HOW TO SCALE UP SAFELY
NEW PARADIGMS
USAGE OF IA+ THREADING

2
ME, MYSELF and I
Been doing multithreading and related
stuff for 20 years, 2/3 C++ 1/3 C#
components and libraries
debugging/revamped applications
Have a blog on it
Proud Father of IA+ Threading (©
SGCIB)
3
First things first
Concurrent computing
Form of computing in which
programs are designed as
collections of interacting
processes
no relation to the hardware it is
running on
4
First things first
Parallel computing
Form of computing in which
calculations are carried out
simultaneously
Implies that multiple processors are
available
5
The Free Lunch is
over
Famous speech (2005) where Herb Sutter
stressed out that
CPU Frequency was no longer
progressing
Developers have to face concurrent
programming to expect to benefit from
newer CPU
but concurrent programming is hard
7
IT IS HARD

8
HOWEVER
EXPERIENCED YOU
MAY BE

9
INCREDIBLY HARD

10
!

	
  	
  	
  	
  	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  lock	
  (_synchro)	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  if	
  (!_stopSignal)	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  Monitor.Wait(_synchro);	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  	
  //	
  second	
  thread	
  logic	
  
	
  	
  	
  	
  	
  private	
  void	
  SecondRunner()	
  
	
  	
  	
  	
  	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  lock	
  (_synchro)	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  if	
  (!_stopSignal)	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  Monitor.Wait(_synchro);	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  	
  }	
  
}	
  

//	
  Let's	
  start	
  easy	
  to	
  put	
  things	
  in	
  motion	
  
internal	
  class	
  DeadLock1	
  
{	
  
	
  	
  	
  	
  private	
  Thread	
  _firstRunner;	
  
	
  	
  	
  	
  private	
  Thread	
  _secondRunner;	
  
	
  	
  	
  	
  private	
  bool	
  _stopSignal	
  =	
  false;	
  
	
  	
  	
  	
  private	
  readonly	
  object	
  _synchro	
  =	
  new	
  
object();	
  

!

	
  	
  	
  	
  public	
  DeadLock1()	
  
	
  	
  	
  	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  _firstRunner	
  =	
  new	
  Thread(FirstRunner);	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  _secondRunner	
  =	
  new	
  Thread(SecondRunner);	
  
	
  	
  	
  	
  }	
  

!

	
  	
  	
  	
  	
  //	
  start	
  your	
  engines	
  
	
  	
  	
  	
  public	
  void	
  Start()	
  
	
  	
  	
  	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  _firstRunner.Start();	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  _secondRunner.Start();	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  Thread.Sleep(100);	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  lock	
  (_synchro)	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  _stopSignal	
  =	
  true;	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  Monitor.Pulse(_synchro);	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  _firstRunner.Join();	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  _secondRunner.Join();	
  
	
  	
  	
  	
  	
  }	
  

	
  	
  	
  class	
  Program	
  
{	
  
	
  	
  	
  	
  static	
  void	
  Main(string[]	
  args)	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  DeadLock1	
  sample1	
  =	
  new	
  DeadLock1();	
  
	
  	
  	
  	
  	
  	
  	
  	
  sample1.Start();	
  }	
  
}

!
!
!
!

	
  	
  	
  	
  	
  //	
  first	
  thread	
  logic	
  
	
  	
  	
  	
  	
  private	
  void	
  FirstRunner()	
  

11
THIS ONE WAS EASY
In the wild, those lines would be
mixed with a lot t business logics and
scaffolding code
!

12
NOT CONVINCED
YET?

13
class C!
{!
static C() !
{!
// Let's run the initialization!
// on another thread!!
var thread = new Thread(Initialize);!
thread.Start();!
thread.Join();!
}!
static void Initialize() { }!
static void Main() { }!
}!

14
IT'S F*CKING HARD
You also need to master the
threading model of the CLR
Of course you need to master the
threading model of libraries
When was the last time you saw
and read a documented threading
model?
15
CAN'T GO BACK the free lunch is over
No complete solutions
RX, TPL: still requires lock
Clojure, ErLang: requires rewiring brain
GO: blocking primitives
Scala, F#: functional+ no thread safety
16
THERE MUST BE
SOMETHING ELSE

17
There is a solution in C#
It avoid locks altogether
It scales well
It does not require full brain rewiring

18
IA+ Threading
Let’s talk patterns
Immutable State
State is a mutable entity by
definition
But can be stored in a Value object
Altering the state means creating a
new version of the state
Immutability is good for sharing
Feedback
Run #1 was chaotic while run #2
was smoother
We just went from mutable to
immutable
Message passing
We also passed around the state of
the object as a message
Originaly used for commands but
works well with state as well
Since state is preserved, no need for
copies!
You just demonstrated
lock free concurrency
Congrats!
What about
causality?
How can we ensure events are
properly taken into accounts?
By the way, what do we mean by
'properly'?
Causality
1. Events can be totally ordered for
any given objects (source or dest)
2. There may not a be a total order
for all events and for all objects
Relativiy
Thanks to relativity, we know that
any two events can be SEEN in any
order
As long as they do not occur at the
same location
Order of magnitude
Pragmatic view
Events must be kept in their natural
local order
Generated events also must be kept
in the order they were generated
General ordering must remain
acceptable for a human

More Related Content

What's hot

Theorical 1
Theorical 1Theorical 1
Theorical 1everblut
 
Presentation on nesting of loops
Presentation on nesting of loopsPresentation on nesting of loops
Presentation on nesting of loopsbsdeol28
 
並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~
並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~
並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~Kazuhiro Eguchi
 
Teorical 1
Teorical 1Teorical 1
Teorical 1everblut
 
Lecture15 comparisonoftheloopcontrolstructures.ppt
Lecture15 comparisonoftheloopcontrolstructures.pptLecture15 comparisonoftheloopcontrolstructures.ppt
Lecture15 comparisonoftheloopcontrolstructures.ppteShikshak
 
OTcl and C++ linkages in NS2
OTcl and C++ linkages in NS2OTcl and C++ linkages in NS2
OTcl and C++ linkages in NS2Pradeep Kumar TS
 
Cpp loop types
Cpp loop typesCpp loop types
Cpp loop typesRj Baculo
 
PHP Lecture 2 - Conditional Statement, Loop
PHP Lecture 2 - Conditional Statement, LoopPHP Lecture 2 - Conditional Statement, Loop
PHP Lecture 2 - Conditional Statement, LoopAl-Mamun Sarkar
 
Functional Reactive Programming avec RxSwift
Functional Reactive Programming avec RxSwiftFunctional Reactive Programming avec RxSwift
Functional Reactive Programming avec RxSwiftNicolas VERINAUD
 

What's hot (19)

Theorical 1
Theorical 1Theorical 1
Theorical 1
 
Unbounded
UnboundedUnbounded
Unbounded
 
Unbounded
UnboundedUnbounded
Unbounded
 
Presentation on nesting of loops
Presentation on nesting of loopsPresentation on nesting of loops
Presentation on nesting of loops
 
並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~
並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~
並行処理プログラミングの深淵~Java仮想マシン仕様 スレッドとロック~
 
Teorical 1
Teorical 1Teorical 1
Teorical 1
 
Free FreeRTOS Course-Task Management
Free FreeRTOS Course-Task ManagementFree FreeRTOS Course-Task Management
Free FreeRTOS Course-Task Management
 
Lecture15 comparisonoftheloopcontrolstructures.ppt
Lecture15 comparisonoftheloopcontrolstructures.pptLecture15 comparisonoftheloopcontrolstructures.ppt
Lecture15 comparisonoftheloopcontrolstructures.ppt
 
The Loops
The LoopsThe Loops
The Loops
 
OTcl and C++ linkages in NS2
OTcl and C++ linkages in NS2OTcl and C++ linkages in NS2
OTcl and C++ linkages in NS2
 
Loops in c++
Loops in c++Loops in c++
Loops in c++
 
Programming ii
Programming iiProgramming ii
Programming ii
 
Cpp loop types
Cpp loop typesCpp loop types
Cpp loop types
 
Looping in c++
Looping in c++Looping in c++
Looping in c++
 
PHP Lecture 2 - Conditional Statement, Loop
PHP Lecture 2 - Conditional Statement, LoopPHP Lecture 2 - Conditional Statement, Loop
PHP Lecture 2 - Conditional Statement, Loop
 
Functional Reactive Programming avec RxSwift
Functional Reactive Programming avec RxSwiftFunctional Reactive Programming avec RxSwift
Functional Reactive Programming avec RxSwift
 
Loop
LoopLoop
Loop
 
04 threads
04 threads04 threads
04 threads
 
13 life and scope
13 life and scope13 life and scope
13 life and scope
 

Similar to Scaling Up Safely with IA+ Threading

Verilog Lecture5 hust 2014
Verilog Lecture5 hust 2014Verilog Lecture5 hust 2014
Verilog Lecture5 hust 2014Béo Tú
 
Let's Talk Locks!
Let's Talk Locks!Let's Talk Locks!
Let's Talk Locks!C4Media
 
.NET Multithreading/Multitasking
.NET Multithreading/Multitasking.NET Multithreading/Multitasking
.NET Multithreading/MultitaskingSasha Kravchuk
 
Parallel Programming With Dot Net
Parallel Programming With Dot NetParallel Programming With Dot Net
Parallel Programming With Dot NetNeeraj Kaushik
 
Spin Locks and Contention : The Art of Multiprocessor Programming : Notes
Spin Locks and Contention : The Art of Multiprocessor Programming : NotesSpin Locks and Contention : The Art of Multiprocessor Programming : Notes
Spin Locks and Contention : The Art of Multiprocessor Programming : NotesSubhajit Sahu
 
Multithreading Introduction and Lifecyle of thread
Multithreading Introduction and Lifecyle of threadMultithreading Introduction and Lifecyle of thread
Multithreading Introduction and Lifecyle of threadKartik Dube
 
Effective java - concurrency
Effective java - concurrencyEffective java - concurrency
Effective java - concurrencyfeng lee
 
Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!olracoatalub
 
【Unite 2017 Tokyo】パフォーマンス向上のためのスクリプトのベストプラクティス(note付き)
【Unite 2017 Tokyo】パフォーマンス向上のためのスクリプトのベストプラクティス(note付き)【Unite 2017 Tokyo】パフォーマンス向上のためのスクリプトのベストプラクティス(note付き)
【Unite 2017 Tokyo】パフォーマンス向上のためのスクリプトのベストプラクティス(note付き)Unity Technologies Japan K.K.
 
Asynchronous Python A Gentle Introduction
Asynchronous Python A Gentle IntroductionAsynchronous Python A Gentle Introduction
Asynchronous Python A Gentle IntroductionPyData
 
Programming in Java: Getting Started
Programming in Java: Getting StartedProgramming in Java: Getting Started
Programming in Java: Getting StartedMartin Chapman
 
OpenThink Labs Training : Diving into Java, Breaking the Surface
OpenThink Labs Training : Diving into Java, Breaking the SurfaceOpenThink Labs Training : Diving into Java, Breaking the Surface
OpenThink Labs Training : Diving into Java, Breaking the SurfaceWildan Maulana
 

Similar to Scaling Up Safely with IA+ Threading (20)

Javascript Best Practices
Javascript Best PracticesJavascript Best Practices
Javascript Best Practices
 
Verilog Lecture5 hust 2014
Verilog Lecture5 hust 2014Verilog Lecture5 hust 2014
Verilog Lecture5 hust 2014
 
Let's Talk Locks!
Let's Talk Locks!Let's Talk Locks!
Let's Talk Locks!
 
.NET Multithreading/Multitasking
.NET Multithreading/Multitasking.NET Multithreading/Multitasking
.NET Multithreading/Multitasking
 
Parallel Programming With Dot Net
Parallel Programming With Dot NetParallel Programming With Dot Net
Parallel Programming With Dot Net
 
storm-170531123446.pptx
storm-170531123446.pptxstorm-170531123446.pptx
storm-170531123446.pptx
 
concurrency
concurrencyconcurrency
concurrency
 
Java Concurrency
Java ConcurrencyJava Concurrency
Java Concurrency
 
Spin Locks and Contention : The Art of Multiprocessor Programming : Notes
Spin Locks and Contention : The Art of Multiprocessor Programming : NotesSpin Locks and Contention : The Art of Multiprocessor Programming : Notes
Spin Locks and Contention : The Art of Multiprocessor Programming : Notes
 
Multithreading Introduction and Lifecyle of thread
Multithreading Introduction and Lifecyle of threadMultithreading Introduction and Lifecyle of thread
Multithreading Introduction and Lifecyle of thread
 
Effective java - concurrency
Effective java - concurrencyEffective java - concurrency
Effective java - concurrency
 
Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!
 
【Unite 2017 Tokyo】パフォーマンス向上のためのスクリプトのベストプラクティス(note付き)
【Unite 2017 Tokyo】パフォーマンス向上のためのスクリプトのベストプラクティス(note付き)【Unite 2017 Tokyo】パフォーマンス向上のためのスクリプトのベストプラクティス(note付き)
【Unite 2017 Tokyo】パフォーマンス向上のためのスクリプトのベストプラクティス(note付き)
 
Thread
ThreadThread
Thread
 
Asynchronous Python A Gentle Introduction
Asynchronous Python A Gentle IntroductionAsynchronous Python A Gentle Introduction
Asynchronous Python A Gentle Introduction
 
concurrency_c#_public
concurrency_c#_publicconcurrency_c#_public
concurrency_c#_public
 
Programming in Java: Getting Started
Programming in Java: Getting StartedProgramming in Java: Getting Started
Programming in Java: Getting Started
 
java_threads.ppt
java_threads.pptjava_threads.ppt
java_threads.ppt
 
Storm
StormStorm
Storm
 
OpenThink Labs Training : Diving into Java, Breaking the Surface
OpenThink Labs Training : Diving into Java, Breaking the SurfaceOpenThink Labs Training : Diving into Java, Breaking the Surface
OpenThink Labs Training : Diving into Java, Breaking the Surface
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 

Scaling Up Safely with IA+ Threading

  • 2. WHAT YOU WILL LEARN TODAY HOW TO SCALE UP SAFELY NEW PARADIGMS USAGE OF IA+ THREADING 2
  • 3. ME, MYSELF and I Been doing multithreading and related stuff for 20 years, 2/3 C++ 1/3 C# components and libraries debugging/revamped applications Have a blog on it Proud Father of IA+ Threading (© SGCIB) 3
  • 4. First things first Concurrent computing Form of computing in which programs are designed as collections of interacting processes no relation to the hardware it is running on 4
  • 5. First things first Parallel computing Form of computing in which calculations are carried out simultaneously Implies that multiple processors are available 5
  • 6.
  • 7. The Free Lunch is over Famous speech (2005) where Herb Sutter stressed out that CPU Frequency was no longer progressing Developers have to face concurrent programming to expect to benefit from newer CPU but concurrent programming is hard 7
  • 11. !          {                    lock  (_synchro)                    {                              if  (!_stopSignal)                              {                                        Monitor.Wait(_synchro);                              }                    }            }            //  second  thread  logic            private  void  SecondRunner()            {                    lock  (_synchro)                    {                            if  (!_stopSignal)                            {                                    Monitor.Wait(_synchro);                            }                    }            }   }   //  Let's  start  easy  to  put  things  in  motion   internal  class  DeadLock1   {          private  Thread  _firstRunner;          private  Thread  _secondRunner;          private  bool  _stopSignal  =  false;          private  readonly  object  _synchro  =  new   object();   !        public  DeadLock1()          {                    _firstRunner  =  new  Thread(FirstRunner);                    _secondRunner  =  new  Thread(SecondRunner);          }   !          //  start  your  engines          public  void  Start()          {                    _firstRunner.Start();                    _secondRunner.Start();                    Thread.Sleep(100);                    lock  (_synchro)                    {                            _stopSignal  =  true;                            Monitor.Pulse(_synchro);                    }                    _firstRunner.Join();                    _secondRunner.Join();            }        class  Program   {          static  void  Main(string[]  args)  {                  DeadLock1  sample1  =  new  DeadLock1();                  sample1.Start();  }   } ! ! ! !          //  first  thread  logic            private  void  FirstRunner()   11
  • 12. THIS ONE WAS EASY In the wild, those lines would be mixed with a lot t business logics and scaffolding code ! 12
  • 14. class C! {! static C() ! {! // Let's run the initialization! // on another thread!! var thread = new Thread(Initialize);! thread.Start();! thread.Join();! }! static void Initialize() { }! static void Main() { }! }! 14
  • 15. IT'S F*CKING HARD You also need to master the threading model of the CLR Of course you need to master the threading model of libraries When was the last time you saw and read a documented threading model? 15
  • 16. CAN'T GO BACK the free lunch is over No complete solutions RX, TPL: still requires lock Clojure, ErLang: requires rewiring brain GO: blocking primitives Scala, F#: functional+ no thread safety 16
  • 18. There is a solution in C# It avoid locks altogether It scales well It does not require full brain rewiring 18
  • 21. Immutable State State is a mutable entity by definition But can be stored in a Value object Altering the state means creating a new version of the state Immutability is good for sharing
  • 22. Feedback Run #1 was chaotic while run #2 was smoother We just went from mutable to immutable
  • 23. Message passing We also passed around the state of the object as a message Originaly used for commands but works well with state as well Since state is preserved, no need for copies!
  • 24. You just demonstrated lock free concurrency Congrats!
  • 25. What about causality? How can we ensure events are properly taken into accounts? By the way, what do we mean by 'properly'?
  • 26. Causality 1. Events can be totally ordered for any given objects (source or dest) 2. There may not a be a total order for all events and for all objects
  • 27. Relativiy Thanks to relativity, we know that any two events can be SEEN in any order As long as they do not occur at the same location
  • 29. Pragmatic view Events must be kept in their natural local order Generated events also must be kept in the order they were generated General ordering must remain acceptable for a human