GlusterFS1
Concurrent is NOT Parallel
Joseph Fernandes
Senior Software Engineer, Red Hat Storage
GlusterFS2
Who am I ?
● Joseph Fernandes (Senior Software Engineer, Red Hat
Storage)
● Gluster Data Tiering
● YADL (Deduplication)
● Gluster Archival/Compliance – WORM/Retention
GlusterFS3
Agenda
● What is Concurrency ?
● What is Parallelism ?
● Concurrency with Parallelism
● Just Concurrent Not Parallel
● Advantages vs Disadvantages
● Programming Language support
● C
● C++
● GO
GlusterFS4
What is Concurrency?
Concurrency is about dealing with lots of things at
once.
GlusterFS5
What is Concurrency?
Masala Dosa
&
Coffee…. Hmmm
EAT
DRINK
LEAVE
Place order
Place order
Order
Ready
Order
Ready
GlusterFS6
What is Concurrency?
GlusterFS7
What is Parallelism?
Parallelism is about doing lots of things at once.
GlusterFS8
What is Parallelism?
Masala Dosa
&
Coffee…. Hmmm
EAT
DRINK
LEAVE
Place order
Place order
Order
Ready
Order
Ready
Waiting or
Doing
something
CLONE1
CLONE2
GlusterFS9
What is Parallelism?
GlusterFS10
Concurrency with Parallelism
Food
Order
Queue
Prepared
Food
Queue
Concurrent
Order Receiver
Concurrent
Dosa Master
Concurrent
Customer
Context
Switch
GlusterFS11
Concurrency with Parallelism
Concurrent
Customers
Food
Order
Queue
Prepared
Food
Queue
Concurrent + Parallel
Order Receivers
Concurrent + Parallel
Dosa Masters
GlusterFS12
Similarity with IO systems
Application
IO API
Blocking
IO Calls
Concurrent
IO Thread
Concurrent
IO Thread
Concurrent
IO Thread
IO Device
Interface
Thread 1
Thread 2
Thread 3
Context Memory
Context Memory
GlusterFS13
More Simplified ..
Thread1 {
Block1() {
Yield()
}
Continue
}
Thread2 {
Block2() {
Yield ()
}
Continue
}
Thread3 {
Block3() {
Yield ()
}
Continue
}
Context Memory
(Will be waked
when unblocked
error or success)
Concurrent
IO Thread
GlusterFS14
More Simplified
Context memory
Wakeup1()
Concurrent
IO Thread
Thread1
Wakeup2()
Thread2
Wakeup3()
Thread3
Sleep() until
Something
comes
In the context
memory
GlusterFS15
Just Concurrent Not Parallel
consume () {
char a = '';
while (a == getchar()) {
//do somehing with a
}
}
producer () {
{
char a = ''
while (doing something) {
a = somecompute to produce;
putchar (a);
}
}
Interesting problem : How do I communicate memory
without having multiple threads/processes?
GlusterFS16
Just Concurrent Not Parallel
Producer () produces 'a'
consumer () consumes 'a'
Producer () produces 'b'
consumer () consumes 'b'
Producer () produces 'EOF'
And returns
consumer () consumes 'EOF'
And returns
Thread 1
GlusterFS17
Co-routines
Coroutines are computer program components that generalize subroutines for
nonpreemptive multitasking, by allowing multiple entry points for suspending and
resuming execution at certain locations.
GlusterFS18
Advantages
● Improved performance and responsiveness
● More real-life approach of solving problems
● Code is more modular and hence less duplication
● Efficient use of Multi-Core CPUs
GlusterFS19
Things to remember
● Increase memory footprints
● Complex Algorithms for implementation
● Dangerous concurrency and synchronization bugs
● Complex Debugging : Bugs, Memory Leaks,
Deadlocks etc
● Performance Backfire : Sloppy design
● Code Portability
GlusterFS20
Programming Language Support : C
● Pthread
● Mutex locks
● Condition Variables
● Atomic Variables
● setjmp, sigsetjmp, longjmp, siglongjmp - performing a
nonlocal goto
GlusterFS21
Programming Language Support : C++
● Support as C
● Coroutines
● Boost Library
● C++17
GlusterFS22
Programming Language Support : GO
● Goroutines
● Go Channels
GlusterFS23
References
● http://tutorials.jenkov.com/java-concurrency/concurrency-vs
● https://en.wikipedia.org/wiki/Concurrent_computing
● http://blog.golang.org/concurrency-is-not-parallelism
● http://stackoverflow.com/questions/1050222/concurrency-v
GlusterFS24
THANK YOU

Concurrent vsparallel