SlideShare a Scribd company logo
Parallel Processing 
A Simple Case Study
Parallel Processing - What is it? 
• Concurrent System 
– Two or more actions progressing in parallel 
– This can be on a single core 
• Parallel System 
– Two or more actions executing in parallel 
– This requires multiple cores 
– Parallel systems are a subset of concurrent systems 
• Distributed System 
– Two or more actions executing in parallel 
– This requires multiple connected machines 
– Communication is primarily via messaging
Why application developers need to 
know? 
• Multi-core processors 
• Large volume of data 
• Analytics and other new fields 
• Cheaper hardware
OS Resource Challenges 
Memory 
(ROM/ 
RAM) 
DB NW NW 
Web 
CPU 
Registers 
Cache 
Service 
Queue 
Distribu 
ted 
Mem
Representation of an Application 
Source Data Transform Data Sink 
- UI 
- DB 
- Queue 
- Network 
- Service 
- UI 
- DB 
- Queue 
- Network 
- Service
Abstraction of Concurrancy 
• Programs are execution of atomic 
statements 
• Concurrent programs are the interleavings 
of atomic statements 
• All possible interleavings should produce 
the same results 
• No process should be excluded from any 
arbitrary interleaving
Challenges 
• Race Conditions 
• Deadlocks
To go Parallel? 
• SpeedUp 
– Amdahl’s Law 
• Speedup <= 1/((1 – PCTpar) + (PCTpar/P)) 
– PCTpar -> percentage of time in parallel 
– P -> Number of cores 
• 75% PCTpar provides 3x speedup on a 8 core 
– Gustafson-Barsis’s Law 
• Speedup <= P + (1 – P) S 
– P -> Number of cores 
– S -> Percentage of time spend in serial code 
• Efficiency 
– Speedup/Cores -> resource utilization as %age
Things to Consider 
• Identify independent computations 
• Implement concurrancy at the highest level 
• Make no assumptions on the cores 
• Use the best processing model 
• Never assume a particular execution order 
• User thread local storage or associate locks 
to specific data 
• Make no assumptions on the order of 
execution
Methedology 
• Start with a tuned and functional serial code 
• Analysis: identify possible concurrancy 
– Identify hotspots probably using profilers 
• Calculate speedup and efficiency 
• Design and implementation 
• Test for correctness 
– Loop executions, rounding errors 
• Tune for performance 
– Enough work load to compensate for overheads 
• Measure Speedup as a multiplier (e.g. 2x faster) 
– Serial code elapsed time/parallel code elapsed time
Sample Process State Diagram 
Shared 
Variable
Highlights of Process Development 
• Single threaded functional code (Java) 
• Threads spawned off for each message 
– Data decomposition 
– Task decomposition 
– Concurrency at the highest level 
• Monitor (synchronize) & conditional variable 
• Code to ignore deadlocks 
• Tested and tuned to remove bottlenecks 
• Scalable for any number of cores
Monitor 
public class Monitor { 
private static int count = 0; 
private static int max = 0; 
public boolean isSemaphoreUsed() 
{ 
return (count < max); 
} 
public Semaphore(int num) { 
count = num; 
max = num; 
} 
private synchronized void 
incCount() { 
count++; 
} 
private synchronized void 
decCount() { 
count--; 
} 
public synchronized void acquire() 
{ 
try { 
while (count == 0) { 
} 
decCount(); 
} 
public synchronized void release() 
{ 
incCount(); 
} 
} 
Never comes 
out
Monitor with Conditional Variables 
public class Monitor { 
private static int count = 0; 
private static int max = 0; 
public boolean isSemaphoreUsed() 
{ 
return (count < max); 
} 
public Semaphore(int num) { 
count = num; 
max = num; 
} 
private synchronized void 
incCount() { 
count++; 
} 
private synchronized void 
decCount() { 
count--; 
} 
public synchronized void acquire() 
{ 
try { 
while (count == 0) { 
this.wait(); 
} 
decCount(); 
} catch (InterruptedException e) 
{} 
} 
public synchronized void release() 
{ 
incCount(); 
this.notify(); 
} 
}
General Design Guidelines 
• Keep it simple stupid (KISS) 
– Break the problem into simple components 
• Keep the number of layers to minimum 
– Don’t add layers since they are hot in industry 
• Do the right thing 
– Skeptics will provide scenarios to take care
bnair@asquareb.com 
blog.asquareb.com 
https://github.com/bijugs 
@gsbiju

More Related Content

PDF
Netezza workload management
PDF
HBase 0.20.0 Performance Evaluation
PDF
HBase Application Performance Improvement
PPTX
Apache HBase Performance Tuning
PDF
Whitepaper: Where did my CPU go?
PPTX
Time-Series Apache HBase
PPT
Hw09 Monitoring Best Practices
PPTX
PostgreSQL Hangout Parameter Tuning
Netezza workload management
HBase 0.20.0 Performance Evaluation
HBase Application Performance Improvement
Apache HBase Performance Tuning
Whitepaper: Where did my CPU go?
Time-Series Apache HBase
Hw09 Monitoring Best Practices
PostgreSQL Hangout Parameter Tuning

What's hot (20)

PDF
The Google Chubby lock service for loosely-coupled distributed systems
PDF
Whitepaper: Exadata Consolidation Success Story
PDF
Tales from the Cloudera Field
PPTX
HBaseCon 2013: How to Get the MTTR Below 1 Minute and More
PDF
Apache HBase in the Enterprise Data Hub at Cerner
PPTX
Apache HBase, Accelerated: In-Memory Flush and Compaction
PDF
HBase Sizing Guide
PDF
HBaseCon 2015: HBase at Scale in an Online and High-Demand Environment
PDF
Hotsos 2011: Mining the AWR repository for Capacity Planning, Visualization, ...
PPTX
The Magic of Tuning in PostgreSQL
PPTX
HBase Accelerated: In-Memory Flush and Compaction
PDF
HBaseCon 2013: Scalable Network Designs for Apache HBase
PDF
Geographically Distributed PostgreSQL
PPTX
Lessons Learned From Running 1800 Clusters (Brooke Jensen, Instaclustr) | Cas...
PDF
HBase Blockcache 101
PDF
Overview of Postgres Utility Processes
 
PPTX
HBase and HDFS: Understanding FileSystem Usage in HBase
PDF
HBaseCon 2012 | HBase and HDFS: Past, Present, Future - Todd Lipcon, Cloudera
PDF
Large-scale Web Apps @ Pinterest
PPT
ha_module5
The Google Chubby lock service for loosely-coupled distributed systems
Whitepaper: Exadata Consolidation Success Story
Tales from the Cloudera Field
HBaseCon 2013: How to Get the MTTR Below 1 Minute and More
Apache HBase in the Enterprise Data Hub at Cerner
Apache HBase, Accelerated: In-Memory Flush and Compaction
HBase Sizing Guide
HBaseCon 2015: HBase at Scale in an Online and High-Demand Environment
Hotsos 2011: Mining the AWR repository for Capacity Planning, Visualization, ...
The Magic of Tuning in PostgreSQL
HBase Accelerated: In-Memory Flush and Compaction
HBaseCon 2013: Scalable Network Designs for Apache HBase
Geographically Distributed PostgreSQL
Lessons Learned From Running 1800 Clusters (Brooke Jensen, Instaclustr) | Cas...
HBase Blockcache 101
Overview of Postgres Utility Processes
 
HBase and HDFS: Understanding FileSystem Usage in HBase
HBaseCon 2012 | HBase and HDFS: Past, Present, Future - Todd Lipcon, Cloudera
Large-scale Web Apps @ Pinterest
ha_module5
Ad

Viewers also liked (7)

PDF
Websphere MQ (MQSeries) fundamentals
PDF
HDFS User Reference
PDF
Using Netezza Query Plan to Improve Performace
PDF
Project Risk Management
PDF
Row or Columnar Database
PDF
Netezza fundamentals for developers
PDF
NENUG Apr14 Talk - data modeling for netezza
Websphere MQ (MQSeries) fundamentals
HDFS User Reference
Using Netezza Query Plan to Improve Performace
Project Risk Management
Row or Columnar Database
Netezza fundamentals for developers
NENUG Apr14 Talk - data modeling for netezza
Ad

Similar to Concurrency (20)

PPTX
Apache Big Data 2016: Next Gen Big Data Analytics with Apache Apex
PPTX
Intro to Apache Apex - Next Gen Platform for Ingest and Transform
PDF
3.2 Streaming and Messaging
PPTX
Speed up R with parallel programming in the Cloud
PDF
Performance Scenario: Diagnosing and resolving sudden slow down on two node RAC
PDF
Predicting Optimal Parallelism for Data Analytics
PPTX
Week1 Electronic System-level ESL Design and SystemC Begin
PDF
Introduction to Apache Apex by Thomas Weise
PPTX
Flink Streaming Hadoop Summit San Jose
PDF
Oracle GoldenGate Architecture Performance
PPTX
Hadoop Summit SJ 2016: Next Gen Big Data Analytics with Apache Apex
PDF
Building Big Data Streaming Architectures
PPTX
introduction to node.js
PPTX
Next Gen Big Data Analytics with Apache Apex
PDF
Performance Analysis: new tools and concepts from the cloud
PPSX
GE IOT Predix Time Series & Data Ingestion Service using Apache Apex (Hadoop)
PDF
Groovy concurrency
PPTX
Jvm memory model
PDF
Spark Summit EU talk by Ram Sriharsha and Vlad Feinberg
PDF
OGG Architecture Performance
Apache Big Data 2016: Next Gen Big Data Analytics with Apache Apex
Intro to Apache Apex - Next Gen Platform for Ingest and Transform
3.2 Streaming and Messaging
Speed up R with parallel programming in the Cloud
Performance Scenario: Diagnosing and resolving sudden slow down on two node RAC
Predicting Optimal Parallelism for Data Analytics
Week1 Electronic System-level ESL Design and SystemC Begin
Introduction to Apache Apex by Thomas Weise
Flink Streaming Hadoop Summit San Jose
Oracle GoldenGate Architecture Performance
Hadoop Summit SJ 2016: Next Gen Big Data Analytics with Apache Apex
Building Big Data Streaming Architectures
introduction to node.js
Next Gen Big Data Analytics with Apache Apex
Performance Analysis: new tools and concepts from the cloud
GE IOT Predix Time Series & Data Ingestion Service using Apache Apex (Hadoop)
Groovy concurrency
Jvm memory model
Spark Summit EU talk by Ram Sriharsha and Vlad Feinberg
OGG Architecture Performance

More from Biju Nair (8)

PDF
Chef conf-2015-chef-patterns-at-bloomberg-scale
PDF
HBase Internals And Operations
PDF
Apache Kafka Reference
PDF
Serving queries at low latency using HBase
PDF
Multi-Tenant HBase Cluster - HBaseCon2018-final
PDF
Cursor Implementation in Apache Phoenix
PDF
Hadoop security
PDF
Chef patterns
Chef conf-2015-chef-patterns-at-bloomberg-scale
HBase Internals And Operations
Apache Kafka Reference
Serving queries at low latency using HBase
Multi-Tenant HBase Cluster - HBaseCon2018-final
Cursor Implementation in Apache Phoenix
Hadoop security
Chef patterns

Recently uploaded (20)

PDF
Modernizing your data center with Dell and AMD
PDF
cuic standard and advanced reporting.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
A Presentation on Artificial Intelligence
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Big Data Technologies - Introduction.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Encapsulation theory and applications.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
Modernizing your data center with Dell and AMD
cuic standard and advanced reporting.pdf
Empathic Computing: Creating Shared Understanding
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Advanced methodologies resolving dimensionality complications for autism neur...
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Reach Out and Touch Someone: Haptics and Empathic Computing
NewMind AI Weekly Chronicles - August'25 Week I
A Presentation on Artificial Intelligence
The AUB Centre for AI in Media Proposal.docx
Big Data Technologies - Introduction.pptx
MYSQL Presentation for SQL database connectivity
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Building Integrated photovoltaic BIPV_UPV.pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Encapsulation theory and applications.pdf
Review of recent advances in non-invasive hemoglobin estimation

Concurrency

  • 1. Parallel Processing A Simple Case Study
  • 2. Parallel Processing - What is it? • Concurrent System – Two or more actions progressing in parallel – This can be on a single core • Parallel System – Two or more actions executing in parallel – This requires multiple cores – Parallel systems are a subset of concurrent systems • Distributed System – Two or more actions executing in parallel – This requires multiple connected machines – Communication is primarily via messaging
  • 3. Why application developers need to know? • Multi-core processors • Large volume of data • Analytics and other new fields • Cheaper hardware
  • 4. OS Resource Challenges Memory (ROM/ RAM) DB NW NW Web CPU Registers Cache Service Queue Distribu ted Mem
  • 5. Representation of an Application Source Data Transform Data Sink - UI - DB - Queue - Network - Service - UI - DB - Queue - Network - Service
  • 6. Abstraction of Concurrancy • Programs are execution of atomic statements • Concurrent programs are the interleavings of atomic statements • All possible interleavings should produce the same results • No process should be excluded from any arbitrary interleaving
  • 7. Challenges • Race Conditions • Deadlocks
  • 8. To go Parallel? • SpeedUp – Amdahl’s Law • Speedup <= 1/((1 – PCTpar) + (PCTpar/P)) – PCTpar -> percentage of time in parallel – P -> Number of cores • 75% PCTpar provides 3x speedup on a 8 core – Gustafson-Barsis’s Law • Speedup <= P + (1 – P) S – P -> Number of cores – S -> Percentage of time spend in serial code • Efficiency – Speedup/Cores -> resource utilization as %age
  • 9. Things to Consider • Identify independent computations • Implement concurrancy at the highest level • Make no assumptions on the cores • Use the best processing model • Never assume a particular execution order • User thread local storage or associate locks to specific data • Make no assumptions on the order of execution
  • 10. Methedology • Start with a tuned and functional serial code • Analysis: identify possible concurrancy – Identify hotspots probably using profilers • Calculate speedup and efficiency • Design and implementation • Test for correctness – Loop executions, rounding errors • Tune for performance – Enough work load to compensate for overheads • Measure Speedup as a multiplier (e.g. 2x faster) – Serial code elapsed time/parallel code elapsed time
  • 11. Sample Process State Diagram Shared Variable
  • 12. Highlights of Process Development • Single threaded functional code (Java) • Threads spawned off for each message – Data decomposition – Task decomposition – Concurrency at the highest level • Monitor (synchronize) & conditional variable • Code to ignore deadlocks • Tested and tuned to remove bottlenecks • Scalable for any number of cores
  • 13. Monitor public class Monitor { private static int count = 0; private static int max = 0; public boolean isSemaphoreUsed() { return (count < max); } public Semaphore(int num) { count = num; max = num; } private synchronized void incCount() { count++; } private synchronized void decCount() { count--; } public synchronized void acquire() { try { while (count == 0) { } decCount(); } public synchronized void release() { incCount(); } } Never comes out
  • 14. Monitor with Conditional Variables public class Monitor { private static int count = 0; private static int max = 0; public boolean isSemaphoreUsed() { return (count < max); } public Semaphore(int num) { count = num; max = num; } private synchronized void incCount() { count++; } private synchronized void decCount() { count--; } public synchronized void acquire() { try { while (count == 0) { this.wait(); } decCount(); } catch (InterruptedException e) {} } public synchronized void release() { incCount(); this.notify(); } }
  • 15. General Design Guidelines • Keep it simple stupid (KISS) – Break the problem into simple components • Keep the number of layers to minimum – Don’t add layers since they are hot in industry • Do the right thing – Skeptics will provide scenarios to take care