Slides from my session on GPars at Gr8Conf EU 2012. It was a manifesto speech for using actors, dataflow, CSP and data parallelism and avoiding all explicit locking and indeed explicit shared-memory multi-threading.
Scanning the Internet for External Cloud Exposures via SSL Certs
GPars
1. GPars
The concurrency and parallelism framework
for Groovy and Java applications
Russel Winder
@russel_winder russel@winder.org.uk
http://www.russel.org.uk
2. Aims and Goals
Convince people that they:
– Can deal with parallelism and concurrency without fear.
– Already understand GPars.
– Can use GPars tonight.
–…
3. …should tremble in fear at
the prospect of using
shared-memory multi-threading
with Java…
8. Concurrency is a tool for structuring
execution where a single processor
is used by multiple computations.
Parallelism is about making a
computation complete faster than
using a single processor.
31. Dataflow
Actors Operators connected by
channels with activity
Independent processes triggered by arrival of
communicating via data on the channels.
asynchronous exchange
of messages
CSP
Sequential processes
connected by channels
using synchronous message
exchange (rendezvous).
31
39. Approximating
What is it's value represented as a floating point number?
– We can only obtain an approximation.
– A plethora of possible algorithms to choose from, a popular
one is to employ the following integral equation.
1 1
=∫0 dx
4 1x 2
39
40. One Possible Algorithm
Use quadrature to estimate the value of the integral –
which is the area under the curve.
4 n 1
Embarrassingly parallel. = ∑i=1
n i−0.5 2
1
n
With n = 3 not much to do,
but potentially lots of error.
Use n = 107 or n = 109?
40
41. Commutative and Associative
Because addition is commutative and
associative, expression can be
decomposed into sums of partial sums.
41
50. The Sleeping Barber Problem
The barber's shop has a single If the barber is cutting, a new
cutting chair and a row of customer checks to see if
waiting seats. there is a free waiting seat.
The barber sleeps in the cutting – If there is join the
chair unless trimming a queue to be
customer. trimmed.
Customers arrive at the shop at – If there isn't leave
intervals. disgruntled.
If the barber is asleep, the
customer wakes the barber Problem originally due
sits in the cutting chair and to Edsger Dijkstra.
gets a trim. 50
51. The cutting chair.
The waiting chairs.
The barber's shop.
A new customer enters the shop,
check to see if they can go straight
to the cutting chair, if not can they
take a waiting chair, if not leave. 51
52. Wikipedia article presents the classic operating
systems approach using locks and semaphores.
http://en.wikipedia.org/wiki/Sleeping_barber_problem
52