SlideShare ist ein Scribd-Unternehmen logo
1 von 57
@gfraiteur
Surmounting complexity by raising abstraction
Multithreading Design Patterns
Gaël Fraiteur
PostSharp Technologies
Founder & Principal Engineer
@gfraiteur
Hello!
My name is GAEL.
No, I don’t think
my accent is funny.
my twitter
@gfraiteur
My commitment to you:
to seed a vision, not to sell a tool.
@gfraiteur
The vision:
Code at the right level of abstraction,
with compiler-supported design patterns
@gfraiteur
back in
1951
@gfraiteur
hardware was fun
but quite simple to use
@gfraiteur
Univac Assembly Language
@gfraiteur
FORTRAN (1955)
• 1955 - FORTRAN I
• Global Variables
• Arrays
• 1958 - FORTRAN II
• Procedural Programming
(no recursion)
• Modules
@gfraiteur
COBOL (1959)
• Data Structures
@gfraiteur
LISP (1959)
• Variable Scopes (Stack)
• Garbage Collection
@gfraiteur
The new invention caught quickly, no wonder, programs
computing nuclear power reactor parameters took now
HOURS INSTEAD OF WEEKS
to write, and required much
LESS PROGRAMMING SKILL
@gfraiteur
1. The Memory Management Revolution
2. Models and Patterns
3. Defining Threading Models
4. Designing with Threading Models
5. A Few Threading Models
6. Q&A
7. Summary
Section
@gfraiteur
How do programming languages
increase productivity?
@gfraiteur
What you
may think
the compiler
does for you.
Code Validation
Instruction Generation
@gfraiteur
Compilers translate code
FROM HIGH
TO LOW ABSTRACTION language
@gfraiteur
Languages let us express
ourselves against a model
Thing Concept Word
Model Language
∞ 1
World
abstracted into expressed with
∞ ∞
1 1
∞
1
1 1
abstracted into expressed with
@gfraiteur
Good Models are Easy
• Allow for succinct expression of intent (semantics), with less
focus on implementation details
• less work
• fewer things to think about
• Allow for extensive validation of source code against the model
• early detection of errors
• Allow for better locality and separation of concerns
• “everything is related to everything” no more
• Are deterministic
• no random error
@gfraiteur
Good Models are Friendly
• to human mind structure
• cope with limited human cognitive abilities
• to social organization
• cope with skillset differences, division of labor,
time dimension, changes in requirements
@gfraiteur
The Classic Programming Model
Quality Realization
Succinct semantics • Concept of subroutine
• Unified concept of variable
(global, local, parameters, fields)
Validation • Syntactic (spelling)
• Semantic (type analysis)
• Advanced (data flow analysis)
Locality • Information hiding (member visibility)
• Modularity
Determinism • Total (uninterrupted single-threaded program)
@gfraiteur
1. The Memory Management Revolution
2. Models and Patterns
3.Defining Threading Models
4. Designing with Threading Models
5. A Few Threading Models
6. Q&A
7. Summary
Section
@gfraiteur
Why we need threading models
• Multithreading is way too hard – today
• Too many things to think about
• Too many side effects
• Random data races
• Your colleagues won’t get smarter
• Increased demand – end of free lunch
@gfraiteur
@gfraiteur
The Root of All Evil
Access to Shared Mutable State
• Memory ordering
• Atomicity / transactions
• Typical damage: data races
• Corruption of data structures
• Invalid states
@gfraiteur
Locks alone are
not the solution
@gfraiteur
@gfraiteur
Locks alone are
not the solution
• Easy to forget
• Difficult to test
• Deadlocks
@gfraiteur
"Problems cannot be solved by
the same level of thinking that
created them."
(and you’re not a man if you haven’t cited Albert Einstein)
@gfraiteur
Threading Models
Reader-Writer
Sync’ed
Pessimistic
Transactions
Lock-Based
Lock-Free
Optimistic
Transactions
Transactional
Avoid Mutable State
Thread Exclusive
Immutable
Actor
Avoid Shared Mutable State
Avoid Shared State
@gfraiteur
• Named solution
• Best practice
• Documented
• Abstraction
• Automation
• Validation
• Determinism
Threading Models are…
Models Design Patterns
@gfraiteur
1. The Memory Management Revolution
2. Models and Patterns
3. Defining Threading Models
4.Designing with Threading Models
5. A Few Threading Models
6. Q&A
7. Summary
Section
@gfraiteur
Golden rule: all shared state must be thread-safe.
@gfraiteur
Assign threading models
to types
1. Every class must be assigned a threading model.
2. Define aggregates with appropriate granularity.
1.
@gfraiteur
Product
Invoice
Party
Store
Invoice InvoiceLine
Product
-lines
1
-invoice
*
-product *
1
Party
-invoices1
-customer*
ProductPart-parts
1
-product
*
Address
-addresses
1*
StockItem
Store
-items 1
-store *
*
-part1
reader-writer-
synchronized
reader-writer-
synchronizedreader-writer-
synchronized
actor
@gfraiteur
Ensure only thread-safe
types are shared
1. Arguments of cross-thread methods
2. All static fields must be read-only
and of thread-safe type.
2.
@gfraiteur
1. The Memory Management Revolution
2. Models and Patterns
3. Defining Threading Models
4. Designing with Threading Models
5. A Few Threading Models
6. Q&A
7. Summary
Section
@gfraiteur
Immutable Pattern
Never changed after creation.
Make a copy if you want to modify it.
Issue: multi-step object
initialization (e.g. deserialization)
@gfraiteur
Freezable Pattern
1. Implement interface IFreezable
Freeze() must propagate to
children objects.
2. Before any non-const method, throw exception if
object is frozen.
3. Call the Freeze method after any initialization.
@gfraiteur
Thread Exclusive
Promises never to be involved
with multithreading. Ever.
@gfraiteur
Thread Exclusivity Strategies
• Exclusivity Policies:
• Thread Affinity (e.g. GUI objects)
• Instance-Level Exclusivity (e.g. most .NET objects)
• Type-Level Exclusivity
• Concurrency Behavior:
• Fail with exception
• Wait with a lock
@gfraiteur
Implementing
Thread Affine Objects
• Remember current thread in constructor
• Verify current thread in any public method
• Prevent field access from outside current instance
• Only private/protected fields
• Only accessed in “this.field”
@gfraiteur
Implementing Thread Excluse
Objects
• Acquire lock before any public method
• Wait/throw if it cannot be acquired
• Prevent field access from outside current instance
• Only private/protected fields
• Only accessed in “this.field”
• Note: “Throw” behavior is non-deterministic
@gfraiteur
Stricter coding constraints increase code verifiability.
@gfraiteur
Lab:
Checking Thread Exclusivity
@gfraiteur
Actor Model
Bound to a single thread
(at a time)
@gfraiteur
Message
Queue
Private
Mutable
State
Single
Worker
Actors:
No Mutable
Shared State
@gfraiteur
Composing Actors
@gfraiteur
Actor Sequence Diagram
Object1 Object2 Object3
Request1 Request2
Response1
Response2
Wait in
message
queue
@gfraiteur
• with compiler support:
• Erlang,
• F# Mailbox
• PostSharp
• without compiler
support:
• NAct
• ActorFX
Actor implementations
@gfraiteur
Verifying the Actor Model
• Public methods will be made async
• Parameters and return values
of public methods must be thread-safe
• Methods with return value must be async
• Prevent field access from outside current instance
• Only private/protected fields
• Only accessed in “this.field”
@gfraiteur
Lab: Implementing Actors
@gfraiteur
• Performance
• Theoretical Latency: min 20 ns
(L3 double-trip)
• Practical throughput (ring
buffer): max 6 MT/s per core
• Difficult to write
without proper
compiler support
• Reentrance issues with
waiting points (await)
• Race free (no shared
mutable state)
• Lock free (no waiting,
no deadlock)
• Scales across processes,
machines
Actors
Benefits Limitations
@gfraiteur
Reader-Writer Synchronized
Everybody can read unless someone writes.
@gfraiteur
Reader-Writer Synchronized
• 1 lock per [group of] objects
• e.g. invoice and invoice lines share the same lock
• Most public methods require locks:
Method Required Lock Level
Reads 1 piece of state None
Reads 2 pieces of state Read
Writes 1 piece of state Write
Reads large amount of state,
then writes state
Upgradeable Read, then
Write
@gfraiteur
Lab: Implementing RWS
@gfraiteur
Transactions
• Isolate shared state into thread-specific storage
• Commit/Rollback semantics
• Platform ensures ACID properties:
• Atomicity, Consistency, Isolation, (Durability)
• Type of concurrency policies
• Pessimistic (lock-based: several “isolation levels”
available)
• Optimistic (lock-free, retry-based)
As far as I'm concerned, I prefer silent vice
to ostentatious virtue. Albert Einstein“
@gfraiteur
Q&A
Gael Fraiteur
gael@postsharp.net
@gfraiteur
@gfraiteur
Summary
• Repeat the memory management
success with the multicore issue.
• Models decrease complexity to
a cognitively bearable level.
• We need compilers that allow
us to use our own models
and patterns.
BETTER SOFTWARE THROUGH SIMPLER CODE

Weitere ähnliche Inhalte

Was ist angesagt?

프로그래머를 위한 360VR
프로그래머를 위한 360VR프로그래머를 위한 360VR
프로그래머를 위한 360VRyorung
 
What’s new in Apache Spark 2.3 and Spark 2.4
What’s new in Apache Spark 2.3 and Spark 2.4What’s new in Apache Spark 2.3 and Spark 2.4
What’s new in Apache Spark 2.3 and Spark 2.4DataWorks Summit
 
Apache Pulsar with MQTT for Edge Computing - Pulsar Summit Asia 2021
Apache Pulsar with MQTT for Edge Computing - Pulsar Summit Asia 2021Apache Pulsar with MQTT for Edge Computing - Pulsar Summit Asia 2021
Apache Pulsar with MQTT for Edge Computing - Pulsar Summit Asia 2021StreamNative
 
Spack - A Package Manager for HPC
Spack - A Package Manager for HPCSpack - A Package Manager for HPC
Spack - A Package Manager for HPCinside-BigData.com
 
Data weave 2.0 advanced (recursion, pattern matching)
Data weave 2.0   advanced (recursion, pattern matching)Data weave 2.0   advanced (recursion, pattern matching)
Data weave 2.0 advanced (recursion, pattern matching)ManjuKumara GH
 
Delivering Agile Data Science on Openshift - Red Hat Summit 2019
Delivering Agile Data Science on Openshift  - Red Hat Summit 2019Delivering Agile Data Science on Openshift  - Red Hat Summit 2019
Delivering Agile Data Science on Openshift - Red Hat Summit 2019John Archer
 
Write microservice in golang
Write microservice in golangWrite microservice in golang
Write microservice in golangBo-Yi Wu
 
(Re)Indexing Large Repositories in Alfresco
(Re)Indexing Large Repositories in Alfresco(Re)Indexing Large Repositories in Alfresco
(Re)Indexing Large Repositories in AlfrescoAngel Borroy López
 
MuleSoft Sizing Guidelines - VirtualMuleys
MuleSoft Sizing Guidelines - VirtualMuleysMuleSoft Sizing Guidelines - VirtualMuleys
MuleSoft Sizing Guidelines - VirtualMuleysAngel Alberici
 
Data Monitoring with whylogs
Data Monitoring with whylogsData Monitoring with whylogs
Data Monitoring with whylogsAlexey Grigorev
 
Building your First gRPC Service
Building your First gRPC ServiceBuilding your First gRPC Service
Building your First gRPC ServiceJessie Barnett
 
The World works in Parallel | Hamidreza Soleimani | Diginext Academy
The World works in Parallel | Hamidreza Soleimani | Diginext AcademyThe World works in Parallel | Hamidreza Soleimani | Diginext Academy
The World works in Parallel | Hamidreza Soleimani | Diginext AcademyHamidreza Soleimani
 
Creating modern java web applications based on struts2 and angularjs
Creating modern java web applications based on struts2 and angularjsCreating modern java web applications based on struts2 and angularjs
Creating modern java web applications based on struts2 and angularjsJohannes Geppert
 
Visual Studio Code 快速上手指南
Visual Studio Code 快速上手指南Visual Studio Code 快速上手指南
Visual Studio Code 快速上手指南Shengyou Fan
 
Collaborative Filtering with Spark
Collaborative Filtering with SparkCollaborative Filtering with Spark
Collaborative Filtering with SparkChris Johnson
 
Git and Github slides.pdf
Git and Github slides.pdfGit and Github slides.pdf
Git and Github slides.pdfTilton2
 

Was ist angesagt? (20)

프로그래머를 위한 360VR
프로그래머를 위한 360VR프로그래머를 위한 360VR
프로그래머를 위한 360VR
 
What’s new in Apache Spark 2.3 and Spark 2.4
What’s new in Apache Spark 2.3 and Spark 2.4What’s new in Apache Spark 2.3 and Spark 2.4
What’s new in Apache Spark 2.3 and Spark 2.4
 
Apache Pulsar with MQTT for Edge Computing - Pulsar Summit Asia 2021
Apache Pulsar with MQTT for Edge Computing - Pulsar Summit Asia 2021Apache Pulsar with MQTT for Edge Computing - Pulsar Summit Asia 2021
Apache Pulsar with MQTT for Edge Computing - Pulsar Summit Asia 2021
 
Spack - A Package Manager for HPC
Spack - A Package Manager for HPCSpack - A Package Manager for HPC
Spack - A Package Manager for HPC
 
GoLang Introduction
GoLang IntroductionGoLang Introduction
GoLang Introduction
 
Data weave 2.0 advanced (recursion, pattern matching)
Data weave 2.0   advanced (recursion, pattern matching)Data weave 2.0   advanced (recursion, pattern matching)
Data weave 2.0 advanced (recursion, pattern matching)
 
Delivering Agile Data Science on Openshift - Red Hat Summit 2019
Delivering Agile Data Science on Openshift  - Red Hat Summit 2019Delivering Agile Data Science on Openshift  - Red Hat Summit 2019
Delivering Agile Data Science on Openshift - Red Hat Summit 2019
 
Fig 9-03
Fig 9-03Fig 9-03
Fig 9-03
 
Write microservice in golang
Write microservice in golangWrite microservice in golang
Write microservice in golang
 
(Re)Indexing Large Repositories in Alfresco
(Re)Indexing Large Repositories in Alfresco(Re)Indexing Large Repositories in Alfresco
(Re)Indexing Large Repositories in Alfresco
 
MuleSoft Sizing Guidelines - VirtualMuleys
MuleSoft Sizing Guidelines - VirtualMuleysMuleSoft Sizing Guidelines - VirtualMuleys
MuleSoft Sizing Guidelines - VirtualMuleys
 
Data Monitoring with whylogs
Data Monitoring with whylogsData Monitoring with whylogs
Data Monitoring with whylogs
 
Building your First gRPC Service
Building your First gRPC ServiceBuilding your First gRPC Service
Building your First gRPC Service
 
The World works in Parallel | Hamidreza Soleimani | Diginext Academy
The World works in Parallel | Hamidreza Soleimani | Diginext AcademyThe World works in Parallel | Hamidreza Soleimani | Diginext Academy
The World works in Parallel | Hamidreza Soleimani | Diginext Academy
 
Creating modern java web applications based on struts2 and angularjs
Creating modern java web applications based on struts2 and angularjsCreating modern java web applications based on struts2 and angularjs
Creating modern java web applications based on struts2 and angularjs
 
Cloudhub 2.0
Cloudhub 2.0Cloudhub 2.0
Cloudhub 2.0
 
Visual Studio Code 快速上手指南
Visual Studio Code 快速上手指南Visual Studio Code 快速上手指南
Visual Studio Code 快速上手指南
 
Collaborative Filtering with Spark
Collaborative Filtering with SparkCollaborative Filtering with Spark
Collaborative Filtering with Spark
 
Golang workshop
Golang workshopGolang workshop
Golang workshop
 
Git and Github slides.pdf
Git and Github slides.pdfGit and Github slides.pdf
Git and Github slides.pdf
 

Ähnlich wie Multithreading Design Patterns

Игорь Фесенко "Direction of C# as a High-Performance Language"
Игорь Фесенко "Direction of C# as a High-Performance Language"Игорь Фесенко "Direction of C# as a High-Performance Language"
Игорь Фесенко "Direction of C# as a High-Performance Language"Fwdays
 
Industry - Program analysis and verification - Type-preserving Heap Profiler ...
Industry - Program analysis and verification - Type-preserving Heap Profiler ...Industry - Program analysis and verification - Type-preserving Heap Profiler ...
Industry - Program analysis and verification - Type-preserving Heap Profiler ...ICSM 2011
 
Modern Java Concurrency (OSCON 2012)
Modern Java Concurrency (OSCON 2012)Modern Java Concurrency (OSCON 2012)
Modern Java Concurrency (OSCON 2012)Martijn Verburg
 
Search at Twitter: Presented by Michael Busch, Twitter
Search at Twitter: Presented by Michael Busch, TwitterSearch at Twitter: Presented by Michael Busch, Twitter
Search at Twitter: Presented by Michael Busch, TwitterLucidworks
 
Modern Java Concurrency (Devoxx Nov/2011)
Modern Java Concurrency (Devoxx Nov/2011)Modern Java Concurrency (Devoxx Nov/2011)
Modern Java Concurrency (Devoxx Nov/2011)Martijn Verburg
 
Actors and Threads
Actors and ThreadsActors and Threads
Actors and Threadsmperham
 
Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1Andrei KUCHARAVY
 
Concurrency patterns in Ruby
Concurrency patterns in RubyConcurrency patterns in Ruby
Concurrency patterns in RubyThoughtWorks
 
Concurrency patterns in Ruby
Concurrency patterns in RubyConcurrency patterns in Ruby
Concurrency patterns in RubyThoughtWorks
 
Introduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning StudioIntroduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning StudioMuralidharan Deenathayalan
 
Introduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning StudioIntroduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning StudioMuralidharan Deenathayalan
 
Data Science Accelerator Program
Data Science Accelerator ProgramData Science Accelerator Program
Data Science Accelerator ProgramGoDataDriven
 
Pune-Cocoa: Blocks and GCD
Pune-Cocoa: Blocks and GCDPune-Cocoa: Blocks and GCD
Pune-Cocoa: Blocks and GCDPrashant Rane
 
Guide to Destroying Codebases The Demise of Clever Code
Guide to Destroying Codebases   The Demise of Clever CodeGuide to Destroying Codebases   The Demise of Clever Code
Guide to Destroying Codebases The Demise of Clever CodeGabor Varadi
 
TRACK F: OpenCL for ALTERA FPGAs, Accelerating performance and design product...
TRACK F: OpenCL for ALTERA FPGAs, Accelerating performance and design product...TRACK F: OpenCL for ALTERA FPGAs, Accelerating performance and design product...
TRACK F: OpenCL for ALTERA FPGAs, Accelerating performance and design product...chiportal
 
Fault tolerance - look, it's simple!
Fault tolerance - look, it's simple!Fault tolerance - look, it's simple!
Fault tolerance - look, it's simple!Izzet Mustafaiev
 
East Coast DevCon 2014: Concurrency & Parallelism in UE4 - Tips for programmi...
East Coast DevCon 2014: Concurrency & Parallelism in UE4 - Tips for programmi...East Coast DevCon 2014: Concurrency & Parallelism in UE4 - Tips for programmi...
East Coast DevCon 2014: Concurrency & Parallelism in UE4 - Tips for programmi...Gerke Max Preussner
 

Ähnlich wie Multithreading Design Patterns (20)

Design Pattern Automation
Design Pattern AutomationDesign Pattern Automation
Design Pattern Automation
 
Introduction to multicore .ppt
Introduction to multicore .pptIntroduction to multicore .ppt
Introduction to multicore .ppt
 
Игорь Фесенко "Direction of C# as a High-Performance Language"
Игорь Фесенко "Direction of C# as a High-Performance Language"Игорь Фесенко "Direction of C# as a High-Performance Language"
Игорь Фесенко "Direction of C# as a High-Performance Language"
 
Multithreading Fundamentals
Multithreading FundamentalsMultithreading Fundamentals
Multithreading Fundamentals
 
Industry - Program analysis and verification - Type-preserving Heap Profiler ...
Industry - Program analysis and verification - Type-preserving Heap Profiler ...Industry - Program analysis and verification - Type-preserving Heap Profiler ...
Industry - Program analysis and verification - Type-preserving Heap Profiler ...
 
Modern Java Concurrency (OSCON 2012)
Modern Java Concurrency (OSCON 2012)Modern Java Concurrency (OSCON 2012)
Modern Java Concurrency (OSCON 2012)
 
Search at Twitter: Presented by Michael Busch, Twitter
Search at Twitter: Presented by Michael Busch, TwitterSearch at Twitter: Presented by Michael Busch, Twitter
Search at Twitter: Presented by Michael Busch, Twitter
 
Modern Java Concurrency (Devoxx Nov/2011)
Modern Java Concurrency (Devoxx Nov/2011)Modern Java Concurrency (Devoxx Nov/2011)
Modern Java Concurrency (Devoxx Nov/2011)
 
Actors and Threads
Actors and ThreadsActors and Threads
Actors and Threads
 
Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1
 
Concurrency patterns in Ruby
Concurrency patterns in RubyConcurrency patterns in Ruby
Concurrency patterns in Ruby
 
Concurrency patterns in Ruby
Concurrency patterns in RubyConcurrency patterns in Ruby
Concurrency patterns in Ruby
 
Introduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning StudioIntroduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning Studio
 
Introduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning StudioIntroduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning Studio
 
Data Science Accelerator Program
Data Science Accelerator ProgramData Science Accelerator Program
Data Science Accelerator Program
 
Pune-Cocoa: Blocks and GCD
Pune-Cocoa: Blocks and GCDPune-Cocoa: Blocks and GCD
Pune-Cocoa: Blocks and GCD
 
Guide to Destroying Codebases The Demise of Clever Code
Guide to Destroying Codebases   The Demise of Clever CodeGuide to Destroying Codebases   The Demise of Clever Code
Guide to Destroying Codebases The Demise of Clever Code
 
TRACK F: OpenCL for ALTERA FPGAs, Accelerating performance and design product...
TRACK F: OpenCL for ALTERA FPGAs, Accelerating performance and design product...TRACK F: OpenCL for ALTERA FPGAs, Accelerating performance and design product...
TRACK F: OpenCL for ALTERA FPGAs, Accelerating performance and design product...
 
Fault tolerance - look, it's simple!
Fault tolerance - look, it's simple!Fault tolerance - look, it's simple!
Fault tolerance - look, it's simple!
 
East Coast DevCon 2014: Concurrency & Parallelism in UE4 - Tips for programmi...
East Coast DevCon 2014: Concurrency & Parallelism in UE4 - Tips for programmi...East Coast DevCon 2014: Concurrency & Parallelism in UE4 - Tips for programmi...
East Coast DevCon 2014: Concurrency & Parallelism in UE4 - Tips for programmi...
 

Mehr von PostSharp Technologies

Advanced Defensive Coding Techniques (with Introduction to Design by Contract)
Advanced Defensive Coding Techniques (with Introduction to Design by Contract)Advanced Defensive Coding Techniques (with Introduction to Design by Contract)
Advanced Defensive Coding Techniques (with Introduction to Design by Contract)PostSharp Technologies
 
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain ModelsApplying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain ModelsPostSharp Technologies
 
Building Better Architecture with UX-Driven Design
Building Better Architecture with UX-Driven DesignBuilding Better Architecture with UX-Driven Design
Building Better Architecture with UX-Driven DesignPostSharp Technologies
 
Solving Localization Challenges with Design Pattern Automation
Solving Localization Challenges with Design Pattern AutomationSolving Localization Challenges with Design Pattern Automation
Solving Localization Challenges with Design Pattern AutomationPostSharp Technologies
 
Applying a Methodical Approach to Website Performance
Applying a Methodical Approach to Website PerformanceApplying a Methodical Approach to Website Performance
Applying a Methodical Approach to Website PerformancePostSharp Technologies
 
10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware ProgrammingPostSharp Technologies
 
Produce Cleaner Code with Aspect-Oriented Programming
Produce Cleaner Code with Aspect-Oriented ProgrammingProduce Cleaner Code with Aspect-Oriented Programming
Produce Cleaner Code with Aspect-Oriented ProgrammingPostSharp Technologies
 

Mehr von PostSharp Technologies (8)

Advanced Defensive Coding Techniques (with Introduction to Design by Contract)
Advanced Defensive Coding Techniques (with Introduction to Design by Contract)Advanced Defensive Coding Techniques (with Introduction to Design by Contract)
Advanced Defensive Coding Techniques (with Introduction to Design by Contract)
 
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain ModelsApplying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
 
Performance is a Feature!
Performance is a Feature!Performance is a Feature!
Performance is a Feature!
 
Building Better Architecture with UX-Driven Design
Building Better Architecture with UX-Driven DesignBuilding Better Architecture with UX-Driven Design
Building Better Architecture with UX-Driven Design
 
Solving Localization Challenges with Design Pattern Automation
Solving Localization Challenges with Design Pattern AutomationSolving Localization Challenges with Design Pattern Automation
Solving Localization Challenges with Design Pattern Automation
 
Applying a Methodical Approach to Website Performance
Applying a Methodical Approach to Website PerformanceApplying a Methodical Approach to Website Performance
Applying a Methodical Approach to Website Performance
 
10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming
 
Produce Cleaner Code with Aspect-Oriented Programming
Produce Cleaner Code with Aspect-Oriented ProgrammingProduce Cleaner Code with Aspect-Oriented Programming
Produce Cleaner Code with Aspect-Oriented Programming
 

Kürzlich hochgeladen

Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 

Kürzlich hochgeladen (20)

Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 

Multithreading Design Patterns

Hinweis der Redaktion

  1. Good morning! My name is Gael Fraiteur. If you think I have a weird accent and even think I am French, but actually I was grown in Belgium and have lived in Czech Republic for the last 12 years.I have been programming non-stop since age of 11, building my first useful program at 12 – it was still reported in use when I got married. My father has been involved with IT in most of his career and my grandfather was probably one of the first programmers in Belgium.(connect to the audience)My grandfather had a PhD in meteorology. He was involved in early weather prediction computing. It’s always fun to talk with him about these heroic times of computing. By far, the rarest resource was working memory (RAM). They had just a few kilobytes of it, and it has to contain the data and the program. Of course they wrote their code in assembly because the single very optimization was importance.Also, they were moving data between RAM and disk back and forth. Of course we’re still doing that when we need to work with dataset that exceed a few GBs. But even doing that was not enough to keep under the 4KB limit, so they also dynamically loaded and unloaded parts of the program – just to save a few hundred bytes. We’re still doing that today but this is transparent to the application programmer thanks to the concept of virtual memory. Virtual memory is an abstraction layer that hides implementation details. There are other abstraction layers: the operating system, the CLR, the programming languages, and the frameworks. All these layers ultimately allow us to write code at a high level of abstraction, without bothering of implementation details.So, there has been this amazing evolution in sixty years. Most of us here are the third generation of programmers. Our predecessors did a marvelous job. What are our today’s challenges and what will be our contribution? Twenty years from now, will our successors laugh at us, consider our current programming languages as mere evolutions of the assembly language, and most of our code as technical wiring that will then be done automatically by “the machine”? I hope so, I hope our generation will be able to make a difference.Today’s challenge is no longer scarce resources, but multithreading. I think this is the number-one problem that our generation needs to tackle. And I think we should get inspiration from our predecessors: how did they succeed with the memory management problem? What are the lessons we can apply today? In this talk, I will argue that we should once again raise the level of abstraction and, this time, we should investigate how programming languages and compilers could allow for a better use of design patterns – or threading models, in this case.Nine years ago, I started working on an open-source project named PostSharp. Essentially, PostSharp allows developers to write custom attributes that extend the language, because PostSharp post-processes the compiler’s output at build time. Most examples in this talk are written in PostSharp, but this talk is more conceptual than practical, so examples are not a big deal of it.
  2. Three years ago, PostSharp outgrew my capacity to maintain it as a free open-source project and, out of necessity, became a commercial product. In an industry dominated by open source and big platform vendors, to make a living from development tools is extraordinarily difficult. We at PostSharp Technologies have been fortunate enough to succeed in this endeavor. We are grateful for the trust we receive from our customers – from the one-man shop to the largest corporations.This remark should also serve as a disclaimer that this talk shall undoubted be biased by my very source of revenues.However, my commitment to you in this talk is to share the vision which motivates us day after day. This vision is much larger than our product itself, and you can implement it with other tools, perhaps less appropriate – and, hopefully we will be able to spark an idea that will influence the design of future language and compilers.
  3. UNIVAC1 control station
  4. Mercury delay line memory of UNIVAC 1 (1951)  approx. 13 KBhttp://univac1.0catch.com/#b218 channels, each 10 words of 12 6-bit characters http://en.wikipedia.org/wiki/File:Mercury_memory.jpg
  5. Programming for the UNIVAC FAC-TRONIC system, 1935 by Remington Rand inchttp://bitsavers.informatik.uni-stuttgart.de/pdf/univac/univac1/UNIVAC_Programming_Jan53.pdf
  6. http://en.wikipedia.org/wiki/File:FortranCardPROJ039.agr.jpg
  7. LISP 1.5 Programmer’s Manual
  8. http://www.ibiblio.org/pub/languages/fortran/ch1-1.html20x less statements than assembly
  9. http://blog.superfeedr.com/ruby/open/ruby-fibers-may-confuse/
  10. http://www.thefreewallpapers.com/wp-content/uploads/2011/06/Tree-in-nature.jpgNow that even mobile phones have multiple cores, it is no longer original to repeat that the free lunch is over and that software developers must embrace multithreaded programming. Although this is much more complex than single-threaded programming, there’s little chance that software developers are going to get smarter – I mean that our cognitive abilities are not likely to increase so much. Investments in training and other skill improvement are necessary but are not going to bring the order-of-magnitude improvement we need to face tomorrow’s growing challenge. Instead, I believe we should focus breaking down complexity – that is, to it easier to write good software.The software industry faced a similar challenge sixty years ago with memory management, and we should look at how our predecessors tackled the problem. What they did is to define a memory model that was close to the way we humans think, and to build compiler to translate code expressed against this model into code that can be executed by the machine. That is, the first programming languages addressed complexity by raising the abstraction level. We need to repeat this success with multithreading. That is, we need to be able to build code against threading models (or threading patterns), and the compiler or runtime environment should be smart enough to perform deterministic validation of our code.Moreover, I think we need compilers that allow us to define our own models and design patterns. Not only for multithreading, but for any other concern. In an ideal world, humans should tell the machines what needs to be done and not how to do it. In an ideal world, source code should not be significantly more difficult or larger than the description of a solution in natural language.With PostSharp, we are proud to contribute to this v