260 likes | 420 Views
Multi-threaded Active Objects . Ludovic Henrio, Fabrice Huet, Zsolt Istv à n. 6 /2013 – Coordination (Firenze). Agenda. Introduction: Active Objects Issues and Existing Solutions Multi-active Objects : Principles Experiments and Benchmarks Conclusion and Future Works.
E N D
Multi-threaded Active Objects Ludovic Henrio, Fabrice Huet, ZsoltIstvàn 6/2013 – Coordination (Firenze)
Agenda • Introduction: Active Objects • Issues and Existing Solutions • Multi-active Objects: Principles • Experimentsand Benchmarks • Conclusion and Future Works
ASP / ProActive • Active objects, asynchronous communication • Asynchronous method calls with implicit transparent futures • A β = newActive (“A”, …) • V foo = β.bar(param) • ….. • foo.getval( ) a b foo= beta.bar(p) Active objects are the unit of distribution and concurrency (one thread per AO / no data shared) ProActive is a Java library implementing ASP foo.getval( ) foo.getval( ) foo.getval( ) WBN!! Caromel, D., Henrio, L.: A Theory of Distributed Object. Springer-Verlag (2005)
First Class Futures a b f delta.snd(foo) d
Agenda • Introduction: Active Objects • Issues and Existing Solutions • Multi-active Objects: Principles • Experimentsand Benchmarks • Conclusion and Future Works
Active Objects – Limitations • No data sharing – inefficient local parallelism • Parameters of method calls are passed by value • No data race-condition simpler programming + easy distribution • Inefficient local parallelism • Risks of deadlocks, e.g. no re-entrant calls • Active object are single threaded • Re-entrance: Active object deadlocks by waiting on itself (except if first-class futures) • Solution: Modifications to the application logic difficult to program AO1 AO2
Related Work (1): Cooperative multithreading Creol an Jcobox: • Active objects & futures • Cooperative multithreading • All requests servedat the same time • But only one thread active at a time • Explicit release points in the code • Partially solves the re-entrance problem • More difficult to program: less transparency • Possible interleaving still has to be studied (service order?)
Related Work (2): JAC • Declarative parallelization in Java • Expressive (complex) set of annotations • “Reactive” objects • Simulating active objects is possible but not trivial An alternative view: we adapt a simple version of JAC to simple active objects a la ASP to get efficient and easy to program multi-active objects
Agenda • Introduction: Active Objects • Issues and Existing Solutions • Multi-active Objects: Principles • Experimentsand Benchmarks • Conclusion and Future Works
Multi-active objects • A programmingmodel that mixes local parallelism and distribution withhigh-levelprogrammingconstructs • Executeseveralrequests in parallel but in a controlledmanner join() Providedadd, add and monitor are compatible add() { … … } monitor(){… … } add() { … }
SchedulingRequests • An « optimal » requestpolicythat « maximizesparallelism »: • Schedule a new request as soon as possible (whenitis compatible with all the servedones) • Serve it in parallelwith the others • Serves • Either the first request • Or the second if itis compatible with the first one (and the servedones) • Or the third one … compatible
Declarative concurrency by annotating request methods • Groups • (Collection of related methods) • Rules • (Compatibility relationships between groups) Memberships (To which group each method belongs)
More efficiency: Thread management • Too many threads can be harmful: • memory consumption, • too much concurrency wrt number of cores • Possibility to limit the number of threads • Hard limit: strict limit on the number of threads • Soft limit: prevents deadlocksLimit the number of threads that are not in a WBN
Dynamic compatibility: Principle • Compatibility maydepend on object’s state or methodparameters join() Providedthe parameters of add are different add(int n) { … … } add(int n) { … }
Dynamic compatibility: annotations • Define a common parameter for methods in a group • a comparison function between parameters (+local state) to decide compatibility
Hypothesesand programmingmethodology • We trust the programmer : annotations are considered as correct; staticanalysis or dynamicchecksshouldenforcecorrectness in the future • Without annotations, a multi-active objectrunslike an active object • If more parallelismisrequired: • Add annotations corresponding to non-conflictingmethods • Declaredynamic compatibility (seenextslide) • Protectsomememoryaccess (e.g. by locks) and add new annotations • More parallelismMorecomplex code / better performance Easy to program Difficult to program
Agenda • Introduction: Active Objects • Issues and Existing Solutions • Multi-active Objects: Principles • Experiments and Benchmarks • Conclusion and Future Works
Experiment#1: NAS parallel benchmark • Pure parallel application (Java) • No distribution • Comparisonwith hand-written concurrent code • Shows thatwith multi-active objects, parallelcode • Is simplerand shorter • With similarperformance
Multi-active objects are simpler to program Original vs. Multi-active object master/slave pattern for NAS
Performance are similar to hand-writtenconcurrency • Less synchronisation/concurrency code • Withsimilar performances
Experiment#2: CAN Eachpeerisimplemented by a (multi) active object and placed on a machine • Featuresparallelism and distribution • Parallelrouting
Experiment#2: CAN Significant speedup due to parallelisation of communications, while controlling which communications are performed in parallel
Agenda • Introduction: Active Objects • Issues and Existing Solutions • Multi-active Objects: Principles • Experimentsand Benchmarks • Conclusion and Future Works
Conclusion (1/2): a new programming model • Multi-active objects feature: • Active object model • Easy to program • Support for distribution • Local concurrencyand efficiency on multi-cores • Transparent multi-threading • Safe parallel execution • Possibility to write non-blocking re-entrant code • Simple annotations A programming model for locally concurrent and globally distributed objects
Conclusion (2/2): ResultsandStatus • Implemented multi-active objectsaboveProActive Dynamiccompatibility rules and thread limitation • Case studies/benchmarks: NAS, CAN • Specified the semantics of Multi-ASP • Provedthatparallelismismaximised: • Tworequestsserved by twodifferent threads are compatible • Eachrequestisincompatible withanotherrequestserved by the same thread (thatprecedeit) • Nextsteps: • Staticguarantees/verification of annotations • Use the new model (new use-cases and applications) • Provestrongerproperties, mechanisedformalisaiton
Conclusion (2/2): ResultsandStatus • Implemented multi-active objectsaboveProActive Dynamiccompatibility rules and thread limitation • Case studies/benchmarks: NAS, CAN • Specified the semantics of Multi-ASP • Provedthatparallelismismaximised: • Tworequestsserved by twodifferent threads are compatible • Eachrequestisincompatible withanotherrequestserved by the same thread (thatprecedeit) • Nextsteps: • Staticguarantees/verification of annotations • Use the new model (new use-cases and applications) • Provestrongerproperties, mechanisedformalisaiton