SlideShare a Scribd company logo
1 of 46
COSCUP 2022
System Software Track 7/30 12:30 – 13:00
腳踏多條船 –
利用 Coroutine 在 Software Transactional
Memory上進行動態排程
- PunchShadow
2
About Me
Dependable Distributed Network and System Laboratory
@ NTUEE BL 607
Parallel/concurrent programming
Heterogenous computing
Micro-architecture search techniques
Contact:
E-mail: f07921043@ntu.edu.tw
Github: PunchShadow
COSCUP
Conference for Open Source Coders,
Users, and Promoters (COSCUP)
3
4
Agenda
What is Software Transactional Memory (STM)?
Contention in STM
Enable Switching on Transactions
SchedSTM – a Flexible Scheduling Framework for STM
Experiments
Conclusion
5
Agenda
What is Software Transactional Memory (STM)?
Contention in STM
Enable Switching on Transactions
SchedSTM – a Flexible Scheduling Framework for STM
Experiments
Conclusion
Software Transactional Memory (STM)
A model for controlling concurrent memory accesses in the scope of
parallel programming
Optimistic transaction execution
Dynamically detect and resolve memory conflicts
Three guarantees [1.1]:
Atomicity
Consistency
Isolation
6
Advantages of STM
Coarse-grained locking programming interface
Critical sections -> transactions
Non-blocking synchronization
Avoid deadlock
More scalable
Learn more about TM:
Introduction to Transactional Memory and Its Implementation (COSCUP 2021)
7
Transaction Execution Three Phases
Begin
Registration, allocation, notification, …
Proceed
Read/ write address set recording
Memory conflict detection
Store buffering
End (validation)
Consistency: commit, write back data
Inconsistency: abort, rollback data 8
Transaction Optimistic Execution
9
Thread 0 Thread 1
Begin:
x=x+1
y=y+1
End:
Begin:
z=z+1
k=k+1
End:
Begin
x=x+1
y=y+1
End
Tx0: Tx1:
Begin:
k=k+2
End:
Tx2:
Begin
z=z+1
k=k+1
End
Transaction Optimistic Execution
10
Thread 0 Thread 1
Begin:
x=x+1
y=y+1
End:
Begin:
z=z+1
k=k+1
End:
Begin
x=x+1
y=y+1
End Validation
No conflicts
Tx0: Tx1:
Commit
Begin:
k=k+2
End:
Tx2:
Begin
z=z+1
k=k+1
End
Transaction Optimistic Execution
11
Thread 0 Thread 1
Begin:
x=x+1
y=y+1
End:
Begin:
z=z+1
k=k+1
End:
Begin
x=x+1
y=y+1
End
Tx0: Tx1:
Commit
Begin:
k=k+2
End:
Tx2:
Begin
z=z+1
k=k+1
End
Begin
k=k+1
End
Transaction Optimistic Execution
12
Thread 0 Thread 1
Begin:
x=x+1
y=y+1
End:
Begin:
z=z+1
k=k+1
End:
Begin
x=x+1
y=y+1
End
Tx0: Tx1:
Commit
Begin:
k=k+2
End:
Tx2:
Begin
z=z+1
k=k+1
End
Begin
k=k+1
End
Transaction Optimistic Execution
13
Thread 0 Thread 1
Begin:
x=x+1
y=y+1
End:
Begin:
z=z+1
k=k+1
End:
Begin
x=x+1
y=y+1
End
Tx0: Tx1:
Commit
Begin:
k=k+2
End:
Tx2:
Begin
z=z+1
k=k+1
End
Begin
k=k+1
End
Commit
Abort
Transaction Optimistic Execution
14
Thread 0 Thread 1
Begin:
x=x+1
y=y+1
End:
Begin:
z=z+1
k=k+1
End:
Begin
x=x+1
y=y+1
End
Tx0: Tx1:
Commit
Begin:
k=k+2
End:
Tx2:
Begin
z=z+1
k=k+1
End
Begin
k=k+1
End Commit
Abort Aborting a transaction
makes overhead!!
Transaction Optimistic Execution
15
Thread 0 Thread 1
Begin:
x=x+1
y=y+1
End:
Begin:
z=z+1
k=k+1
…
…
…
…
End:
Begin
x=x+1
y=y+1
End
Tx0: Tx1:
Begin:
k=k+2
End:
Tx2:
Begin
z=z+1
k=k+1
End
...
Begin
k=k+1
End
Abort Immediately Restart
Tx2
Begin
k=k+1
End
Transaction Optimistic Execution
16
Thread 0 Thread 1
Begin:
x=x+1
y=y+1
End:
Begin:
z=z+1
k=k+1
…
…
…
…
End:
Begin
x=x+1
y=y+1
End
Tx0: Tx1:
Begin:
k=k+2
End:
Tx2:
Begin
z=z+1
k=k+1
End
...
Begin
k=k+1
End
Abort
Begin
k=k+1
End
Transaction Optimistic Execution
17
Thread 0
Thread 1
Begin:
x=x+1
y=y+1
End:
Begin:
z=z+1
k=k+1
…
…
…
…
End:
Begin
x=x+1
y=y+1
End
Tx0: Tx1:
Begin:
k=k+2
End:
Tx2:
Begin
z=z+1
k=k+1
End
...
Begin
k=k+1
End
Abort
Begin
k=k+1
End
Abort
Repeat aborting transaction
worsens the performance
18
Agenda
What is Software Transactional Memory (STM)?
Contention in STM
Enable Switching on Transactions
SchedSTM – a Flexible Scheduling Framework for STM
Experiments
Conclusion
Contention in STM
When a process scales up
Thread number ↑
Conflict probability ↑
Interleaving conflict probability ↑
Abort ratio ↑
Overhead ↑
Scalability ↓
19
Contention Resolving Techniques
Contention Managers [2.1]
Delaying aborted transactions restarting for reducing repeated conflicts
Schedulers [2.2]
Thread scheduling
Concurrency control -> dynamic adjustment of thread number
Transaction scheduling
Serializing collide transactions
20
STM Execution with 16 threads
21
SU: Suicide(restart); BO: Backoff (CM); ATS: Adaptive Transaction Scheduler
Observations on Previous Works
Previous CMs or schedulers suspend execution for reducing contention
Sacrificing parallelism degree
Seldom of them can further improve performance
Maintaining a level of speedup without improving potential
All of them lack switch action
Similar to OS uses context switch to hide IO latency
22
Observations on Previous Works
23
Trans B
Trans A
Trans B
Thread 0
Thread 1
Trans B Trans B
Thread 1
Trans B
Naïve
(Suicide)
CM
(Backoff)
Trans B Trans B
Thread 1
time
Sched
❷ Immediately restart Trans B. but keeps aborting.
Committed Aborted
❸ Delays the restart of Trans B with undetermined delay
❶ Trans A kills Trans B
❹ Thread 1 halts until Trans A signal
Trans A signal
Trans B Trans B
Thread 1
Oracle
Trans C
❺ Switches to independent Trans C
24
Agenda
What is Software Transactional Memory (STM)?
Contention in STM
Enable Switching on Transactions
SchedSTM – a Flexible Scheduling Framework for STM
Experiments
Conclusion
Switching Transactions
Can the system switch to another transaction during execution?
Programming model
Runtime support
Can we find a non-collide transaction to switch to?
Scheduling algorithm design
25
Programming Model Modification
STM applications are usually iterative convergent. [2.3]
Existing an objective value to minimize or maximize.
Iteratively determining if the objective value is small or big enough.
E.g. machine learning, KNN, NLP, and other scientific computing.
26
Example: Learning A Bayes Network
27
Rain Sprinkler Grass Wet
1 1 1
1 0 1
0 1 0
… … …
Observed data:
Example: Learning A Bayes Network
28
Rain Sprinkler Grass Wet
1 1 1
1 0 1
0 1 0
… … …
Observed data:
Sprinkler Rain
Grass
Wet
Rain
T F
Sprinkler
T F
Rain
T
F
Learn
T F
Rain
T
F
Grass Wet
Sprinkler
F
F
T
T
F
T
0.2 0.8
0.4
0.01
0.6
0.99
0.0 1.0
0.8
0.9
0.99
0.2
0.1
0.01
Example: Learning A Bayes Network
29
Example: Learning A Bayes Network
30
Loop ( Stop Condition)
Example: Learning A Bayes Network
31
Pop iteration arguments
Example: Learning A Bayes Network
32
Computing new objective value
Example: Learning A Bayes Network
33
Determining if the process
converges
Example: Learning A Bayes Network
34
Insert new arguments for next
iteration.
Loop Parallelization + Coroutine
Split iterations to individual tasks [3.4]
A task should be executed serially
But the execution of order between tasks is flexible
Use coroutine to switch between tasks [3.1]
No additional interrupt
Lightweight
Switching is controlled by process
35
36
Transaction A
Transaction B
Transaction C
Loop:
Transaction A
Transaction B
Transaction C
Iteration 0
Iteration 1
Iteration 2
Yield to
Iteration 0’s
Transaction B
Loop Parallelization + Coroutine
parallelization
37
Agenda
What is Software Transactional Memory (STM)?
Contention in STM
Enable Switching on Transactions
SchedSTM – a Flexible Scheduling Framework for STM
Experiments
Conclusion
SchedSTM Objective
Seamless integration of the switch action to STM scheduler
Unified & clear interface
Customized scheduler input information
Runtime conflict tracking
Statistical analysis
Trivial or no modification need on application slide
38
39
Start/Resume
Task
Transaction
Execution
Commit
Abort
Task
Manager
Runtime
Monitor
Transaction
Scheduler
fetch monitor pass, restart, idle trigger
switch
SchedSTM
Finish
Task
ref
Runtime
Initialization
Scheduler
Interface
Configuration
configure
SchedSTM Overview
Runtime Implementation
Work-Stealing Task Queue (WSTQ)
Concurrent queue [3.1]
Pending Task Table (PTT)
Conflict Tracking Table (CTT)
Coroutine Library
libaco [3.2]
STM infrastructure
TinySTM [3.3]
40
core core
core
push pop
steal
yield
push
resume
pull
reference record
WSTQ
PTT
CTT
Task flow
Monitor
flow
Experiments
Environments
Intel Xeon Sliver 4208*2 @ 2.1GHz
Linux kernel 5.13.0
STAMP benchmark suite [3.5]
Switch Scheduler
Adaptive ant colony optimization(ACO)[4.1] scheduler
State-of-the-art
Suicide [3.3]
Shrink [4.2]
Polka [4.3]
41
Experiments (cont.)
42
43
Experiments (cont.)
Conclusion
Switching to another transaction is an indispensable action to avoid
contention overhead.
SchedSTM provides unified and powerful interface for both
scheduler designers and parallel programmers.
Our experiments validates that the addition of switch action can
further improve performance.
44
References
1. Introduction
[1.1] IBM: Transactional memory
[1.2] Meltdown: Reading Kernel Memory from User Space
[1.3] C++-Transactional Memory
2. Contention Resolving Techniques
[2.1] Dragojević, Aleksandar, Rachid Guerraoui, and Michal Kapalka. "Stretching transactional memory." ACM sigplan notices 44.6 (2009):
155-165.
[2.2] Di Sanzo, Pierangelo, et al. "Adaptive model-based scheduling in software transactional memory." IEEE Transactions on
Computers 69.5 (2019): 621-632.
[2.3] Harlap, Aaron, et al. "Addressing the straggler problem for iterative convergent parallel ML." Proceedings of the seventh ACM
symposium on cloud computing. 2016.
45
References (cont.)
3. Implementation
[3.1] Moodycamel::Concurrent queue
[3.2] Libaco – A blazing fast and lightweight C asymmetric coroutine libaray
[3.3] TinySTM Github
[3.4] Aiken, Alexander, and Alexandru Nicolau. "Optimal loop parallelization." ACM SIGPLAN Notices 23.7 (1988): 308-317.
[3.5] STAMP-Standford Transactional Memory for Multi-Processing
4. Experiments
[4.1] Dorigo, Marco, Mauro Birattari, and Thomas Stutzle. "Ant colony optimization." IEEE computational intelligence magazine 1.4 (2006):
28-39.
[4.2] Dragojević, Aleksandar, et al. "Preventing versus curing: avoiding conflicts in transactional memories." Proceedings of the 28th ACM
symposium on Principles of distributed computing. 2009.
[4.3] Scherer III, William N., and Michael L. Scott. "Advanced contention management for dynamic software transactional
memory." Proceedings of the twenty-fourth annual ACM symposium on Principles of distributed computing. 2005.
46

More Related Content

Similar to Flexible STM Scheduling Framework Enables Transaction Switching

RTOS Material hfffffffffffffffffffffffffffffffffffff
RTOS Material hfffffffffffffffffffffffffffffffffffffRTOS Material hfffffffffffffffffffffffffffffffffffff
RTOS Material hfffffffffffffffffffffffffffffffffffffadugnanegero
 
Deep Dive on Amazon EC2 instances
Deep Dive on Amazon EC2 instancesDeep Dive on Amazon EC2 instances
Deep Dive on Amazon EC2 instancesAmazon Web Services
 
IJCER (www.ijceronline.com) International Journal of computational Engineeri...
 IJCER (www.ijceronline.com) International Journal of computational Engineeri... IJCER (www.ijceronline.com) International Journal of computational Engineeri...
IJCER (www.ijceronline.com) International Journal of computational Engineeri...ijceronline
 
System on Chip Based RTC in Power Electronics
System on Chip Based RTC in Power ElectronicsSystem on Chip Based RTC in Power Electronics
System on Chip Based RTC in Power ElectronicsjournalBEEI
 
AWS re:Invent 2016: [JK REPEAT] Deep Dive on Amazon EC2 Instances, Featuring ...
AWS re:Invent 2016: [JK REPEAT] Deep Dive on Amazon EC2 Instances, Featuring ...AWS re:Invent 2016: [JK REPEAT] Deep Dive on Amazon EC2 Instances, Featuring ...
AWS re:Invent 2016: [JK REPEAT] Deep Dive on Amazon EC2 Instances, Featuring ...Amazon Web Services
 
Crash course on data streaming (with examples using Apache Flink)
Crash course on data streaming (with examples using Apache Flink)Crash course on data streaming (with examples using Apache Flink)
Crash course on data streaming (with examples using Apache Flink)Vincenzo Gulisano
 
AWS re:Invent 2016: Deep Dive on Amazon EC2 Instances, Featuring Performance ...
AWS re:Invent 2016: Deep Dive on Amazon EC2 Instances, Featuring Performance ...AWS re:Invent 2016: Deep Dive on Amazon EC2 Instances, Featuring Performance ...
AWS re:Invent 2016: Deep Dive on Amazon EC2 Instances, Featuring Performance ...Amazon Web Services
 
Operating systems question bank
Operating systems question bankOperating systems question bank
Operating systems question bankanuradha raheja
 
Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...
Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...
Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...MLconf
 
Understand and Harness the Capabilities of Intel® Xeon Phi™ Processors
Understand and Harness the Capabilities of Intel® Xeon Phi™ ProcessorsUnderstand and Harness the Capabilities of Intel® Xeon Phi™ Processors
Understand and Harness the Capabilities of Intel® Xeon Phi™ ProcessorsIntel® Software
 
Embedded Intro India05
Embedded Intro India05Embedded Intro India05
Embedded Intro India05Rajesh Gupta
 
Security Monitoring with eBPF
Security Monitoring with eBPFSecurity Monitoring with eBPF
Security Monitoring with eBPFAlex Maestretti
 
CS 542 -- Concurrency Control, Distributed Commit
CS 542 -- Concurrency Control, Distributed CommitCS 542 -- Concurrency Control, Distributed Commit
CS 542 -- Concurrency Control, Distributed CommitJ Singh
 

Similar to Flexible STM Scheduling Framework Enables Transaction Switching (20)

RTOS Material hfffffffffffffffffffffffffffffffffffff
RTOS Material hfffffffffffffffffffffffffffffffffffffRTOS Material hfffffffffffffffffffffffffffffffffffff
RTOS Material hfffffffffffffffffffffffffffffffffffff
 
TiReX: Tiled Regular eXpression matching architecture
TiReX: Tiled Regular eXpression matching architectureTiReX: Tiled Regular eXpression matching architecture
TiReX: Tiled Regular eXpression matching architecture
 
Deep Dive on Amazon EC2 instances
Deep Dive on Amazon EC2 instancesDeep Dive on Amazon EC2 instances
Deep Dive on Amazon EC2 instances
 
Data race
Data raceData race
Data race
 
IJCER (www.ijceronline.com) International Journal of computational Engineeri...
 IJCER (www.ijceronline.com) International Journal of computational Engineeri... IJCER (www.ijceronline.com) International Journal of computational Engineeri...
IJCER (www.ijceronline.com) International Journal of computational Engineeri...
 
System on Chip Based RTC in Power Electronics
System on Chip Based RTC in Power ElectronicsSystem on Chip Based RTC in Power Electronics
System on Chip Based RTC in Power Electronics
 
Ds ppt imp.
Ds ppt imp.Ds ppt imp.
Ds ppt imp.
 
SDN approach.pptx
SDN approach.pptxSDN approach.pptx
SDN approach.pptx
 
AWS re:Invent 2016: [JK REPEAT] Deep Dive on Amazon EC2 Instances, Featuring ...
AWS re:Invent 2016: [JK REPEAT] Deep Dive on Amazon EC2 Instances, Featuring ...AWS re:Invent 2016: [JK REPEAT] Deep Dive on Amazon EC2 Instances, Featuring ...
AWS re:Invent 2016: [JK REPEAT] Deep Dive on Amazon EC2 Instances, Featuring ...
 
Crash course on data streaming (with examples using Apache Flink)
Crash course on data streaming (with examples using Apache Flink)Crash course on data streaming (with examples using Apache Flink)
Crash course on data streaming (with examples using Apache Flink)
 
AWS re:Invent 2016: Deep Dive on Amazon EC2 Instances, Featuring Performance ...
AWS re:Invent 2016: Deep Dive on Amazon EC2 Instances, Featuring Performance ...AWS re:Invent 2016: Deep Dive on Amazon EC2 Instances, Featuring Performance ...
AWS re:Invent 2016: Deep Dive on Amazon EC2 Instances, Featuring Performance ...
 
Operating systems question bank
Operating systems question bankOperating systems question bank
Operating systems question bank
 
Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...
Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...
Alex Smola, Professor in the Machine Learning Department, Carnegie Mellon Uni...
 
Understand and Harness the Capabilities of Intel® Xeon Phi™ Processors
Understand and Harness the Capabilities of Intel® Xeon Phi™ ProcessorsUnderstand and Harness the Capabilities of Intel® Xeon Phi™ Processors
Understand and Harness the Capabilities of Intel® Xeon Phi™ Processors
 
Tridiagonal solver in gpu
Tridiagonal solver in gpuTridiagonal solver in gpu
Tridiagonal solver in gpu
 
Embedded Intro India05
Embedded Intro India05Embedded Intro India05
Embedded Intro India05
 
Linux capacity planning
Linux capacity planningLinux capacity planning
Linux capacity planning
 
Security Monitoring with eBPF
Security Monitoring with eBPFSecurity Monitoring with eBPF
Security Monitoring with eBPF
 
Icin 2009
Icin 2009Icin 2009
Icin 2009
 
CS 542 -- Concurrency Control, Distributed Commit
CS 542 -- Concurrency Control, Distributed CommitCS 542 -- Concurrency Control, Distributed Commit
CS 542 -- Concurrency Control, Distributed Commit
 

Recently uploaded

ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 

Recently uploaded (20)

ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 

Flexible STM Scheduling Framework Enables Transaction Switching

  • 1. COSCUP 2022 System Software Track 7/30 12:30 – 13:00 腳踏多條船 – 利用 Coroutine 在 Software Transactional Memory上進行動態排程 - PunchShadow
  • 2. 2 About Me Dependable Distributed Network and System Laboratory @ NTUEE BL 607 Parallel/concurrent programming Heterogenous computing Micro-architecture search techniques Contact: E-mail: f07921043@ntu.edu.tw Github: PunchShadow
  • 3. COSCUP Conference for Open Source Coders, Users, and Promoters (COSCUP) 3
  • 4. 4 Agenda What is Software Transactional Memory (STM)? Contention in STM Enable Switching on Transactions SchedSTM – a Flexible Scheduling Framework for STM Experiments Conclusion
  • 5. 5 Agenda What is Software Transactional Memory (STM)? Contention in STM Enable Switching on Transactions SchedSTM – a Flexible Scheduling Framework for STM Experiments Conclusion
  • 6. Software Transactional Memory (STM) A model for controlling concurrent memory accesses in the scope of parallel programming Optimistic transaction execution Dynamically detect and resolve memory conflicts Three guarantees [1.1]: Atomicity Consistency Isolation 6
  • 7. Advantages of STM Coarse-grained locking programming interface Critical sections -> transactions Non-blocking synchronization Avoid deadlock More scalable Learn more about TM: Introduction to Transactional Memory and Its Implementation (COSCUP 2021) 7
  • 8. Transaction Execution Three Phases Begin Registration, allocation, notification, … Proceed Read/ write address set recording Memory conflict detection Store buffering End (validation) Consistency: commit, write back data Inconsistency: abort, rollback data 8
  • 9. Transaction Optimistic Execution 9 Thread 0 Thread 1 Begin: x=x+1 y=y+1 End: Begin: z=z+1 k=k+1 End: Begin x=x+1 y=y+1 End Tx0: Tx1: Begin: k=k+2 End: Tx2: Begin z=z+1 k=k+1 End
  • 10. Transaction Optimistic Execution 10 Thread 0 Thread 1 Begin: x=x+1 y=y+1 End: Begin: z=z+1 k=k+1 End: Begin x=x+1 y=y+1 End Validation No conflicts Tx0: Tx1: Commit Begin: k=k+2 End: Tx2: Begin z=z+1 k=k+1 End
  • 11. Transaction Optimistic Execution 11 Thread 0 Thread 1 Begin: x=x+1 y=y+1 End: Begin: z=z+1 k=k+1 End: Begin x=x+1 y=y+1 End Tx0: Tx1: Commit Begin: k=k+2 End: Tx2: Begin z=z+1 k=k+1 End Begin k=k+1 End
  • 12. Transaction Optimistic Execution 12 Thread 0 Thread 1 Begin: x=x+1 y=y+1 End: Begin: z=z+1 k=k+1 End: Begin x=x+1 y=y+1 End Tx0: Tx1: Commit Begin: k=k+2 End: Tx2: Begin z=z+1 k=k+1 End Begin k=k+1 End
  • 13. Transaction Optimistic Execution 13 Thread 0 Thread 1 Begin: x=x+1 y=y+1 End: Begin: z=z+1 k=k+1 End: Begin x=x+1 y=y+1 End Tx0: Tx1: Commit Begin: k=k+2 End: Tx2: Begin z=z+1 k=k+1 End Begin k=k+1 End Commit Abort
  • 14. Transaction Optimistic Execution 14 Thread 0 Thread 1 Begin: x=x+1 y=y+1 End: Begin: z=z+1 k=k+1 End: Begin x=x+1 y=y+1 End Tx0: Tx1: Commit Begin: k=k+2 End: Tx2: Begin z=z+1 k=k+1 End Begin k=k+1 End Commit Abort Aborting a transaction makes overhead!!
  • 15. Transaction Optimistic Execution 15 Thread 0 Thread 1 Begin: x=x+1 y=y+1 End: Begin: z=z+1 k=k+1 … … … … End: Begin x=x+1 y=y+1 End Tx0: Tx1: Begin: k=k+2 End: Tx2: Begin z=z+1 k=k+1 End ... Begin k=k+1 End Abort Immediately Restart Tx2 Begin k=k+1 End
  • 16. Transaction Optimistic Execution 16 Thread 0 Thread 1 Begin: x=x+1 y=y+1 End: Begin: z=z+1 k=k+1 … … … … End: Begin x=x+1 y=y+1 End Tx0: Tx1: Begin: k=k+2 End: Tx2: Begin z=z+1 k=k+1 End ... Begin k=k+1 End Abort Begin k=k+1 End
  • 17. Transaction Optimistic Execution 17 Thread 0 Thread 1 Begin: x=x+1 y=y+1 End: Begin: z=z+1 k=k+1 … … … … End: Begin x=x+1 y=y+1 End Tx0: Tx1: Begin: k=k+2 End: Tx2: Begin z=z+1 k=k+1 End ... Begin k=k+1 End Abort Begin k=k+1 End Abort Repeat aborting transaction worsens the performance
  • 18. 18 Agenda What is Software Transactional Memory (STM)? Contention in STM Enable Switching on Transactions SchedSTM – a Flexible Scheduling Framework for STM Experiments Conclusion
  • 19. Contention in STM When a process scales up Thread number ↑ Conflict probability ↑ Interleaving conflict probability ↑ Abort ratio ↑ Overhead ↑ Scalability ↓ 19
  • 20. Contention Resolving Techniques Contention Managers [2.1] Delaying aborted transactions restarting for reducing repeated conflicts Schedulers [2.2] Thread scheduling Concurrency control -> dynamic adjustment of thread number Transaction scheduling Serializing collide transactions 20
  • 21. STM Execution with 16 threads 21 SU: Suicide(restart); BO: Backoff (CM); ATS: Adaptive Transaction Scheduler
  • 22. Observations on Previous Works Previous CMs or schedulers suspend execution for reducing contention Sacrificing parallelism degree Seldom of them can further improve performance Maintaining a level of speedup without improving potential All of them lack switch action Similar to OS uses context switch to hide IO latency 22
  • 23. Observations on Previous Works 23 Trans B Trans A Trans B Thread 0 Thread 1 Trans B Trans B Thread 1 Trans B Naïve (Suicide) CM (Backoff) Trans B Trans B Thread 1 time Sched ❷ Immediately restart Trans B. but keeps aborting. Committed Aborted ❸ Delays the restart of Trans B with undetermined delay ❶ Trans A kills Trans B ❹ Thread 1 halts until Trans A signal Trans A signal Trans B Trans B Thread 1 Oracle Trans C ❺ Switches to independent Trans C
  • 24. 24 Agenda What is Software Transactional Memory (STM)? Contention in STM Enable Switching on Transactions SchedSTM – a Flexible Scheduling Framework for STM Experiments Conclusion
  • 25. Switching Transactions Can the system switch to another transaction during execution? Programming model Runtime support Can we find a non-collide transaction to switch to? Scheduling algorithm design 25
  • 26. Programming Model Modification STM applications are usually iterative convergent. [2.3] Existing an objective value to minimize or maximize. Iteratively determining if the objective value is small or big enough. E.g. machine learning, KNN, NLP, and other scientific computing. 26
  • 27. Example: Learning A Bayes Network 27 Rain Sprinkler Grass Wet 1 1 1 1 0 1 0 1 0 … … … Observed data:
  • 28. Example: Learning A Bayes Network 28 Rain Sprinkler Grass Wet 1 1 1 1 0 1 0 1 0 … … … Observed data: Sprinkler Rain Grass Wet Rain T F Sprinkler T F Rain T F Learn T F Rain T F Grass Wet Sprinkler F F T T F T 0.2 0.8 0.4 0.01 0.6 0.99 0.0 1.0 0.8 0.9 0.99 0.2 0.1 0.01
  • 29. Example: Learning A Bayes Network 29
  • 30. Example: Learning A Bayes Network 30 Loop ( Stop Condition)
  • 31. Example: Learning A Bayes Network 31 Pop iteration arguments
  • 32. Example: Learning A Bayes Network 32 Computing new objective value
  • 33. Example: Learning A Bayes Network 33 Determining if the process converges
  • 34. Example: Learning A Bayes Network 34 Insert new arguments for next iteration.
  • 35. Loop Parallelization + Coroutine Split iterations to individual tasks [3.4] A task should be executed serially But the execution of order between tasks is flexible Use coroutine to switch between tasks [3.1] No additional interrupt Lightweight Switching is controlled by process 35
  • 36. 36 Transaction A Transaction B Transaction C Loop: Transaction A Transaction B Transaction C Iteration 0 Iteration 1 Iteration 2 Yield to Iteration 0’s Transaction B Loop Parallelization + Coroutine parallelization
  • 37. 37 Agenda What is Software Transactional Memory (STM)? Contention in STM Enable Switching on Transactions SchedSTM – a Flexible Scheduling Framework for STM Experiments Conclusion
  • 38. SchedSTM Objective Seamless integration of the switch action to STM scheduler Unified & clear interface Customized scheduler input information Runtime conflict tracking Statistical analysis Trivial or no modification need on application slide 38
  • 39. 39 Start/Resume Task Transaction Execution Commit Abort Task Manager Runtime Monitor Transaction Scheduler fetch monitor pass, restart, idle trigger switch SchedSTM Finish Task ref Runtime Initialization Scheduler Interface Configuration configure SchedSTM Overview
  • 40. Runtime Implementation Work-Stealing Task Queue (WSTQ) Concurrent queue [3.1] Pending Task Table (PTT) Conflict Tracking Table (CTT) Coroutine Library libaco [3.2] STM infrastructure TinySTM [3.3] 40 core core core push pop steal yield push resume pull reference record WSTQ PTT CTT Task flow Monitor flow
  • 41. Experiments Environments Intel Xeon Sliver 4208*2 @ 2.1GHz Linux kernel 5.13.0 STAMP benchmark suite [3.5] Switch Scheduler Adaptive ant colony optimization(ACO)[4.1] scheduler State-of-the-art Suicide [3.3] Shrink [4.2] Polka [4.3] 41
  • 44. Conclusion Switching to another transaction is an indispensable action to avoid contention overhead. SchedSTM provides unified and powerful interface for both scheduler designers and parallel programmers. Our experiments validates that the addition of switch action can further improve performance. 44
  • 45. References 1. Introduction [1.1] IBM: Transactional memory [1.2] Meltdown: Reading Kernel Memory from User Space [1.3] C++-Transactional Memory 2. Contention Resolving Techniques [2.1] Dragojević, Aleksandar, Rachid Guerraoui, and Michal Kapalka. "Stretching transactional memory." ACM sigplan notices 44.6 (2009): 155-165. [2.2] Di Sanzo, Pierangelo, et al. "Adaptive model-based scheduling in software transactional memory." IEEE Transactions on Computers 69.5 (2019): 621-632. [2.3] Harlap, Aaron, et al. "Addressing the straggler problem for iterative convergent parallel ML." Proceedings of the seventh ACM symposium on cloud computing. 2016. 45
  • 46. References (cont.) 3. Implementation [3.1] Moodycamel::Concurrent queue [3.2] Libaco – A blazing fast and lightweight C asymmetric coroutine libaray [3.3] TinySTM Github [3.4] Aiken, Alexander, and Alexandru Nicolau. "Optimal loop parallelization." ACM SIGPLAN Notices 23.7 (1988): 308-317. [3.5] STAMP-Standford Transactional Memory for Multi-Processing 4. Experiments [4.1] Dorigo, Marco, Mauro Birattari, and Thomas Stutzle. "Ant colony optimization." IEEE computational intelligence magazine 1.4 (2006): 28-39. [4.2] Dragojević, Aleksandar, et al. "Preventing versus curing: avoiding conflicts in transactional memories." Proceedings of the 28th ACM symposium on Principles of distributed computing. 2009. [4.3] Scherer III, William N., and Michael L. Scott. "Advanced contention management for dynamic software transactional memory." Proceedings of the twenty-fourth annual ACM symposium on Principles of distributed computing. 2005. 46