multi-threaded active objects

26
- 1 Multi-threaded Active Objects Ludovic Henrio, Fabrice Huet, Zsolt Istvàn 6/2013 – Coordination (Firenze)

Upload: emelda

Post on 24-Feb-2016

39 views

Category:

Documents


0 download

DESCRIPTION

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. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Multi-threaded Active Objects

Oct. 2012

- 1

Multi-threaded Active Objects

Ludovic Henrio, Fabrice Huet, Zsolt Istvàn

6/2013 – Coordination (Firenze)

Page 2: Multi-threaded Active Objects

Agenda

I. Introduction: Active Objects

II. Issues and Existing Solutions

III. Multi-active Objects: Principles

IV. Experiments and Benchmarks

V. Conclusion and Future Works

2

Page 3: Multi-threaded Active Objects

ASP / ProActive

• Active objects, asynchronous communication • Asynchronous method calls with implicit transparent

futures

ba

WBN!!

foo = beta.bar(p)foo.getval( )foo.getval( )foo.getval( )

Caromel, D., Henrio, L.: A Theory of Distributed Object. Springer-Verlag (2005)

A β = newActive (“A”, …)V foo = β.bar(param)…..foo.getval( )

Active objects are the unit of distribution and concurrency (one thread per AO / no data shared)

ProActive is a Java library implementing ASP

Page 4: Multi-threaded Active Objects

First Class Futures

delta.snd(foo)

ba

d

f

Page 5: Multi-threaded Active Objects

Agenda

I. Introduction: Active Objects

II. Issues and Existing Solutions

III. Multi-active Objects: Principles

IV. Experiments and Benchmarks

V. Conclusion and Future Works

5

Page 6: Multi-threaded Active Objects

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

Page 7: Multi-threaded Active Objects

Related Work (1): Cooperative multithreading

Creol an Jcobox:• Active objects & futures• Cooperative

multithreading All requests served

at 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?)

Page 8: Multi-threaded Active Objects

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

Page 9: Multi-threaded Active Objects

Agenda

I. Introduction: Active Objects

II. Issues and Existing Solutions

III. Multi-active Objects: Principles

IV. Experiments and Benchmarks

V. Conclusion and Future Works

9

Page 10: Multi-threaded Active Objects

Multi-active objects

• A programming model that mixes local parallelism and distribution with high-level programming constructs

• Execute several requests in parallel but in a controlled manner

10

add() {…… }

monitor(){…… }

add() {…}

Provided add, add and monitor are compatible

join

()

Page 11: Multi-threaded Active Objects

Scheduling Requests

• An « optimal » request policy that « maximizes parallelism »:➜ Schedule a new request as soon as possible (when it

is compatible with all the served ones)➜ Serve it in parallel with the others➜ Serves

Either the first request Or the second if it is compatible with the first one

(and the served ones) Or the third one …

11

compatible

Page 12: Multi-threaded Active Objects

Declarative concurrency by annotating request methods

Groups (Collection of related methods)

Rules (Compatibility relationships between groups)

Memberships(To which group each method belongs)

12

Page 13: Multi-threaded Active Objects

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 deadlocks

Limit the number of threads that are not in a WBN

Page 14: Multi-threaded Active Objects

Dynamic compatibility: Principle

• Compatibility may depend on object’s state or method parameters

14

add(int n) {…… }

add(int n) {…}

Provided the parameters of add are different

join

()

Page 15: Multi-threaded Active Objects

Dynamic compatibility: annotations

• Define a common parameter for methods in a group

• a comparison function between parameters (+local state) to decide compatibility

Page 16: Multi-threaded Active Objects

Hypotheses and programming methodology• We trust the programmer : annotations are considered as

correct; static analysis or dynamic checks should enforce correctness in the future

• Without annotations, a multi-active object runs like an active object

• If more parallelism is required:1. Add annotations corresponding to non-conflicting

methods2. Declare dynamic compatibility (see next slide)3. Protect some memory access (e.g. by locks) and add

new annotations

• More parallelismMore complex code / better performance

16

Easy to program

Difficult to program

Page 17: Multi-threaded Active Objects

Agenda

I. Introduction: Active Objects

II. Issues and Existing Solutions

III. Multi-active Objects: Principles

IV. Experiments and Benchmarks

V. Conclusion and Future Works

17

Page 18: Multi-threaded Active Objects

Experiment #1: NAS parallel benchmark

• Pure parallel application (Java)

• No distribution

• Comparison with hand-written concurrent code

• Shows that with multi-active objects, parallel code - Is simpler and shorter - With similar performance

18

Page 19: Multi-threaded Active Objects

Multi-active objects are simpler to program

19

Original vs. Multi-active object master/slave pattern for NAS

Page 20: Multi-threaded Active Objects

Performance are similar to hand-written concurrency

• Less synchronisation/concurrency code

• With similar performances

20

Page 21: Multi-threaded Active Objects

Experiment #2: CAN

• Features parallelism and distribution• Parallel routing

21

Each peer is implemented by a (multi) active object and

placed on a machine

Page 22: Multi-threaded Active Objects

Experiment #2: CAN

22

Significant speedup due to parallelisation of communications, while controlling which communications are performed in parallel

Page 23: Multi-threaded Active Objects

Agenda

I. Introduction: Active Objects

II. Issues and Existing Solutions

III. Multi-active Objects: Principles

IV. Experiments and Benchmarks

V. Conclusion and Future Works

23

Page 24: Multi-threaded Active Objects

Conclusion (1/2): a new programming model

• Multi-active objects feature:- Active object model

Easy to program Support for distribution

- Local concurrency and efficiency on multi-cores Transparent multi-threading Safe parallel execution

- Possibility to write non-blocking re-entrant code- Simple annotationsA programming model for locally concurrent and

globally distributed objects

Page 25: Multi-threaded Active Objects

• Implemented multi-active objects above ProActiveDynamic compatibility rules and thread limitation

• Case studies/benchmarks: NAS, CAN• Specified the semantics of Multi-ASP• Proved that parallelism is maximised:

- Two requests served by two different threads are compatible- Each request is incompatible with another request served by

the same thread (that precede it) • Next steps:

- Static guarantees/verification of annotations- Use the new model (new use-cases and applications)- Prove stronger properties, mechanised formalisaiton

Conclusion (2/2): Results and Status

25

Page 26: Multi-threaded Active Objects

• Implemented multi-active objects above ProActiveDynamic compatibility rules and thread limitation

• Case studies/benchmarks: NAS, CAN• Specified the semantics of Multi-ASP• Proved that parallelism is maximised:

- Two requests served by two different threads are compatible- Each request is incompatible with another request served by

the same thread (that precede it) • Next steps:

- Static guarantees/verification of annotations- Use the new model (new use-cases and applications)- Prove stronger properties, mechanised formalisaiton

Conclusion (2/2): Results and Status

26