SlideShare une entreprise Scribd logo
1  sur  29
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

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
 

Tendances (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
 

Similaire à 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
 

Similaire à 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
 

Dernier

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 

Dernier (20)

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 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