threaded Active Objects Design and Implementation Justine Rochas Thesis supervised by Ludovic Henrio CNRS Reviewers Einar Broch Johnsen University of Oslo ID: 787456
Download The PPT/PDF document "Execution Support for Multi-" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Execution Support for Multi-threaded Active Objects: Design and Implementation
Justine RochasThesis supervised by Ludovic Henrio (CNRS)
Reviewers
Einar
Broch Johnsen University of Oslo Lionel Seinturier Université de LilleExaminers Florian Kammüller Middlesex University London Johan Montagnat CNRS Fabrice Huet Université de Nice Sophia Antipolis
1
Slide2MotivationExample: airline reservation system
ChallengesSimultaneous accesses (concurrency)From anywhere (distribution)Other examples
World wide webMassively
multiplayer online gamesBanking systemsPeer-to-
peer
2
t
ravel
data
booking
Slide3How do I
build
that
?
The
toolboxProgramming modelsProgramming languagesMiddlewaresAPIs
Technologies
3
Slide4Global objectivesHelp the programmer in developing safe
distributed and concurrent systems, easilyOur approachProgramming model (design)Middleware (implementation
)Goals to keep in mind
High level of abstractionCorrect behaviour
4
Slide5OutlineIntroductionActors
Active objectsMultiactive objects
Local scheduling for multiactive
objectsEncoding of cooperative active
objectsSupport for multiactive
objectsConclusion & perspectivesEncodingIntroductionSupportConclusionLocal scheduling5
Slide6The actor programming model (1985)
actor
actor
actor
6
Slide7Active
objects (1996)Object-oriented programming model for
concurrencyAsynchronous
method call (request
)Placeholder for the result (
future)
m
ethod
call
request
SAFE
… NO DATA RACES
7
r
equest
queue
thread
a
ctive
object
Slide8The ProActive middlewareJava library for distributed
active objectsActive + passive objects (activity) Java syntax
& t
ransparent futuresWait
-by-necessity
8
activity
active
object
l
ocal
reference
passive
object
Bar
bar
=
newActive
(
Bar.
class
,
parameters
,
node
);
Foo
foo
=
bar
.compute
();
f
oo
.use
();
Slide9Limitations of active objectsInefficient local parallelismSingle-
threaded data manipulationRisk of deadlocks Circular dependency on future awaitingDeployment challenges
Location transparencyException handlingFault tolerance
…
a
bSAFE… TOO STRICT?9
Slide10Related works: cooperative active objectsExplicit release points in
requests (await)Enable request interleavingCan avoid some deadlocks
Require more skillsCreol (2006)
JCoBox (2010) & ABS (2010)
Sets of active objects sharing one active thread
t
wo
sets of active
objects
smsb
10
Balancer
smsb
= new Balancer(
"sms"
,
15
);
Fut<Int> f =
smsb!sendSms
();
await
f?;
ABS
Slide11Related works: Scala (2006) / Akka (2010)
Single-threaded actorsStill deadlock-prone (futures)Practical aspects fully addressed
11
class
Master
extends Actor { def receive = { case Calculate ⇒ println("Received") context.system.shutdown() }} def calculate(
nbWorkers
: Int) {
val system =
ActorSystem
("
PiSystem
")
val
master
=
system.actorOf
(
Props
[Master
]
,
name
=
"m"
)
val
future
=
master
?
Calculate
val
result
=
Await.result
(
future
,
3 seconds
)
.
asInstanceOf
[String]
}
L
ow-level
configuration mixed
with
the business
logic
Akka
Slide12Multiactive objects (2013)Goal
Local request parallelism (thread-based)ChallengeAvoid data races between requests
PrincipleDeclare compatibility of
requests
SAFE –>
CONTROLLED12
m
ultiple threads
Slide13Multiactive objects in ProActiveClass annotations Parallelisable
requestsadd – loglog – logNot parallelisableadd – add
@
DefineGroups
({
@Group(name="routing", selfCompatible=false), @Group(name="monitoring", selfCompatible=true) })@DefineRules({
@Compatible({
"
routing
"
,
"monitoring"
})
})
class
Peer {
@
MemberOf
(
"
routing
"
)
void
add
(Key k, Data d)
{ …
}
@
MemberOf
(
"monitoring"
)
void
log(String m) { … }
}
13
Slide14Results of the thesisContributions to the multiactive object
frameworkEnhanced local parallelismExecution support at the middleware levelContribution to the active object communityEncoding
of cooperative active objects
Implementation
and formal aspects of active object languages
14
Slide15OutlineIntroductionLocal scheduling
for multiactive objectsDefault schedulingThread limit
PriorityEncoding
of cooperative active objects
Support for multiactive objectsConclusion
EncodingIntroductionSupportConclusionLocal scheduling15
Slide16Default scheduling of multiactive objectsMaximisation of request
parallelismExecute when compatible withExecuting requestsOr ahead in the queue
Too
many
threads
can
be
created
16
Slide17Controlling
threads of multiactive objectsLimit numberGlobal thread
limit Per multiactive object
Limit typeHard thread limit (all threads)
Soft thread limit (active threads)Can be
changed programmatically
@
DefineThreadConfig
(
threadPoolSize
=
2
,
hardLimit
=
false
)
c
lass
Peer {
…
}
17
t
hreads in
wait
-by-
necessity
Slide18max
min
Controlling
threads of
request
groups
…
@
Group(
name
=
"
routing
"
,
selfCompatible
=
false
,
minThreads
=
2
,
maxThreads
=
5
),
…
@
DefineThreadConfig
(
threadPoolSize
=
8
,
hardLimit
=
true
)
c
lass
Peer {
…
}
Threads
never
used
by the
routing
group
The programmer
never
manipulates
threads
directly
18
Slide19Contention in multiactive object
compatible
compatible
thread
limit
= 3
queue
r
eady
queue
Request
priority
! [2]
a
19
[2]
Declarative
Scheduling
for Active
Objects
, SAC 2014
Slide20Priority specification mechanism
…@
DefinePriorities({
@PriorityHierarchy
({ @PrioritySet(groupNames={"G1"}), @PrioritySet(groupNames={"G2"}), @PrioritySet(groupNames={"G4"
,
"G5
"
})
})
@
PriorityHierarchy
({
@
PrioritySet
(
groupNames
={
"
G3"
}),
@
PrioritySet
(
groupNames
={
"
G4"
})
})
})
…
c
lass
Peer {
…
}
G1
G2
G3
G5
G4
high
priority
l
ow
priority
p
riority
graph of
request
groups
20
Slide21Insertion time of requests with priority
transitive graph
21
Same
performance
as integers, but more expressiveInsertion time (ms)Number of requests in the queue
Slide22Related works in active object scheduling
Programmatic schedulers: ABS (2010), Parallel Actor Monitor (2014)PermissiveApplication-level scheduling
: ProActive, Creol (2006)Safer
Different priority locations
22
Slide23Local scheduling for multiactive objectsSafe
ExpressiveEasy to reason aboutEfficentLinked to request groupsConclusion
A
balanced
approach
23
Slide24OutlineIntroductionLocal scheduling
for multiactive objectsEncoding of cooperative active objectsABS
ProActive backend
Fomalisation
Support for multiactive objects
ConclusionEncodingIntroductionSupportConclusionLocal scheduling24
Slide25Motivation & resultsTranslation of ABS programs into ProActive programs
General comparison of active object languages
MODELLING,
VERIFICATION
DEPLOYMENT,
DISTRIBUTED EXECUTIONABS source codeProActive backendProActive generated code25
Slide26The ABS languageActive object modelling
languageConcurrent Object Groups (COG)Explicit syntax (! and Fut<T>)Cooperative
scheduling (await)ToolsetVerification
& program analysis Execution through
backends (Erlang, Haskell, Java…
)COGCOG
A
a
=
new local
A();
B
b
=
new
B(
obj
,
…
);
b
!foo
(
a
);
foo
(A
a
) {
Fut<V>
vFut
=
a
!bar
();
await
vFut
?;
V
v
=
vFut
.
get
;
v
.doSmt
();
}
a
o
x
y
b
26
Slide27Challenges of the translation
ABSProActiveactive object modelobject groups
active & passive objectsasynchronous
calls localdistributed
request scheduling
cooperativemulti-threaded27
Slide28Challenges of the translation
ABSProActiveactive object model
object groups
active & passive objects
asynchronous
calls localdistributedrequest schedulingcooperativemulti-threadedCOG
1 COG = 1 active
object
registry
COG
28
Slide29Translation of a new statement
Server server = new
Server() (1)
COG
cog =
newActive(COG.class, {}, node2) (2)cog.registerObject(server) (3)node1node2Server server = new
Server()
ProActive
ABS
server
c
og
(proxy)
cog
registry
server (copy)
29
(1
) Create Java Object
(2) Create
ProActive
active object
(3)
Make Java object available to
ProActive
active object
Slide30Challenges of the translation
ABSProActiveactive object modelobject groups
active & passive objects
asynchronous calls
local
distributedrequest schedulingcooperativemulti-threadedCOG
Two-level
addressing
system
COG
30
Slide31node2
Translation of an asynchronous call
server
!start()
ABS
node1server.getCog().execute("start", {}, server.getID())ProActive
server
c
og
(proxy)
cog
ID
ref
registry
getCog
start
execute
execute
PASSIVE OBJECTS BECOME REACHABLE
31
server (copy)
Slide32Challenges of the translation
ABSProActiveactive object modelobject groups
active & passive objectsasynchronous
calls localdistributed
request
schedulingcooperativemulti-threadedCOG
Soft thread
limit
COG
32
Slide33Translation of an await statement
@DefineGroups({
@Group(name
="
scheduling"
, selfCompatible=true)})@DefineThreadConfig(threadPoolSize=1, hardLimit=false)public class COG { @MemberOf("
scheduling
"
)
public
ABSType
execute
(…)
{
…
}
}
PAFuture.getFutureValue
(
f
)
ABS
ProActive
await
f
?
33
(1
) Make
execute
requests compatible
(2) Limit the COG to 1 active thread
Simulates
the
execution
transfer
of ABS
Slide34Formalisation: translation correctness [4]
Theorem 1 from ABS to MultiASPTheorem 2 from MultiASP to ABS
MultiASP
Multiactive
Objects
ProActiveAsync. callAsync. callSync. callAssignment≈Return sync.ABSMultiASP
s
ilent
actions
p
rogramming
model
implementation
formalisation
34
[4]
From
Modelling
to
Systematic
Deployment
of
Distributed
Active
Objects
, Coordination 2016
DISTRIBUTED ASPECTS
Slide35On representation of futures…Control flow (ABS
) vs data flow (MultiASP/ProActive)No straight simulation, future indirection must be followed in the proof
≠
i
n ABS
…future f2future f1empty
f
uture f1
empty
35
c
lass
A {
Fut<Int>
foo
() {
B
b
=
new
B();
Fut<Int>
f2
=
b
!bar
();
return
f2
;
}
}
c
lass
B {
Int bar() {
while
True
{
}
}
}
f1
.
get
;
{
A
a
=
new
A();
Fut<Fut<Int>>
f1
=
a
!foo
();
Fut<Int>
f2
=
f1
.
get
;
return
0
;
}
EQUIVALENCE
LOST HERE
{
A
a
=
new
A();
Fut<Fut<Int>>
f1
=
a
!foo
();
Int
i
=
f1
.
get
.
get
;
return
i
;
}
✓
Only
the
progams
with
half-computed
futures
behave
differently
❌
Slide36Restrictions of the translationThe value of a future cannot be a future (from
ABS to MultiASP)FIFO service / Causal ordering of requests (both directions)Distribution of future updates (from MultiASP to ABS)
Restrictions due
to distributed execution
node1
node2
node3
node4
f
f
f
f
v
v
v
v
await
f
?
await
f
?
36
Slide37Systematic deployment of cooperative active objectsCooperative
active objects –> multiactive objectsFaithful translationPractical resultImplemented
backendFormal resultProof of
correctness of the simulationConclusion
Restrictions
were defined thanks to formalisation37
Slide38OutlineIntroductionLocal scheduling
for multiactive objectsEncoding of cooperative active objectsSupport for multiactive objects
Debugging
Fault tolerance
Conclusion
EncodingIntroductionSupportConclusionLocal scheduling38
Slide39Development and execution support
For multiactive objectsHelp in finding bugs
Help with unstable distributed
environments
DEBUGGING
FAULT TOLERANCE39
Slide40Debugger for multiactive objects
Peer 4
Peer 2
Peer 1
Peer 3
40
Slide41Debugging: concurrent read & writes
READ
WRITE
WRITE
41
Slide42Debugging: deadlock
42s
Slide43Fault tolerance
43
Slide44Recover upon faults
request
request
ProActive
active
object
44
Slide45Checkpoint multiactive objects…
WHICH STATE SAVED??
thread 1
thread 2
thread 3
thread 4
ProActive
multiactive
object
45
Slide46Checkpoint with multiactive scheduling
checkpoint
request
, n+1
t
hread
limit
= 1
checkpoint
n
n
+1
request
t
hread
limit
= 3
request
Checkpoint as-a-
request
, thread
limit
, and
priority
46
Slide47Support for multiactive objectsRequest and communication debugger
Several usersAdapted fault tolerance protocolExtracted from the middleware as
multiactive object annotations
conclusion
Implementation of non-functional aspects
thanks to multiactive object scheduling47
Slide48OutlineIntroductionLocal scheduling
for multiactive objectsEncoding of cooperative active objectsSupport for multiactive objects
ConclusionSummary
Perspectives
Encoding
IntroductionSupportConclusionLocal scheduling48
Slide49Recap(plication): peer-to-peer
d?
d
49
Slide50Recap(plication): peer-to-peer
a
50
Multiactive
object annotations
Improved local scheduling
Thread limit & priority
@
DefineGroups
({
@Group(
name
=
"
dataManagement
"
,
selfCompatible
=
false
), @Group(
name
=
"monitoring"
,
selfCompatible
=
true
),
…
})
@
DefineRules
({
@
Compatible
({
"
dataManagement
"
,
"monitoring
"
}),
…
})
@
DefinePriorities
({
@
PriorityHierarchy
({
@
PrioritySet
({
"
dataManagement
"
}),
@
PrioritySet
({
"
monitoring"
}),
…
})
})
@
DefineThreadConfig
(
threadPoolSize
=
2
,
hardLimit
=
false
);
p
ublic
class
Peer {
…
}
Slide51Recap(plication): peer-to-peer
INIT
Efficient &
robust
implementation
of
peer
-
to-peer
system
51
[1] An Optimal Broadcast
Algorithm
for Content-
Addressable
Networks, OPODIS 2013
Slide52COG
Recap
(
plication
): translation
m
ultiactive
object
Equivalent
behaviour
–>
preservation
of
guarantees
52
Translation of cooperative scheduling
Proof of correctness
Efficient
ProActive
backend for ABS
Slide53Conclusion multiactive object framework
Compatibility Multi-threadingPriorityThread limit
Peer-to-peer
Fault tolerance
ProActive
backend for ABS53
CHARACTERISTICS
APPLICATIONS
Slide54PerspectivesThe multiactive object framework
Mature fault toleranceDynamic prioritiesMultiactive objects analysisDeadlock detection
in MultiASP programs (on-going PhD)
Specification and verification of multiactive componentsStatic
analysis of annotations
54@DefineGroups({ @Group(name="routing", …), @Group(name="monitoring", …) })
@
DefineRules
({
@Compatible({
"
routing
"
,
"monitoring"
})
})
class
Peer {
@
MemberOf
(
"
routing
"
)
void
add
(Key k, Data d)
{ …
}
@
MemberOf
(
"monitoring"
)
void
log(String m) { … }
}
Statically
check absence of concurrent
accesses
Slide55Publications[1] Ludovic Henrio, Fabrice
Huet and Justine Rochas. “An Optimal Broadcast Algorithm for Content-Addressable Networks’’. In: Proceedings of the 17th International
Conference on Principles
of Distributed
Systems. OPODIS
2013. [2] Ludovic Henrio and Justine Rochas. “Declarative Scheduling for Active Objects”. In: Proceedings of the 29th Annual ACM Symposium on Applied Computing. SAC 2014. [3] Ge Song, Justine Rochas, Fabrice Huet and Frédéric Magoulès. “Solutions for Processing K Nearest Neighbor Joins for Massive Data on MapReduce”. In: 23rd Euromicro International Conference on Parallel, Distributed and Network-based Processing. PDP 2015.
[
4]
Ludovic
Henrio
and Justine Rochas.
“
From
Modelling
to
Systematic
Deployment
of
Distributed
Active
Objects
”. In: 18th International
Conference
, COORDINATION 2016,
Held
as Part of the 11th International
Federated
Conference
on
Distributed
Computing
Techniques.
DisCoTec
2016.
Selected
for
special
issue of
Logical
Methods
in Computer Science journal.
[
5]
Ge
Song, Justine Rochas, Léa
El
Beze
, Fabrice
Huet and
Frédéric
Magoulès
.
“K
Nearest
Neighbour
Joins for
Big
Data
on
MapReduce
: a
Theoretical
and
Experimental
Analysis
”.
In:
IEEE Transactions on
Knowledge and Data
Engineering. 2016.
55Execution Support for Multi-
threaded Active Objects: Design and
Implementation – Justine Rochas