actor-based programming for scalable concurrent systems

36
Actor-based Programming for Scalable Concurrent Systems Gul Agha http://osl.cs.uiuc.edu

Upload: charis

Post on 09-Jan-2016

40 views

Category:

Documents


3 download

DESCRIPTION

Actor-based Programming for Scalable Concurrent Systems. Gul Agha http://osl.cs.uiuc.edu. Outline. Defining the actor model High-level actor programming languages Implementing actors Orchestrating large numbers of actors. Motivation. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Actor-based Programming for Scalable Concurrent Systems

Actor-based Programming for Scalable Concurrent Systems Gul Agha

http://osl.cs.uiuc.edu

Page 2: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 2

Outline

Defining the actor model High-level actor programming languages Implementing actors Orchestrating large numbers of actors

Page 3: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 3

Motivation

Parallelism provides a natural decomposition of real-world application

Concurrent object-based programming languages can enable modularity in control as well as data.

Distributed programs can be transparently implemented on a variety of architectures Portability as the number of cores changes Seamless integration with sensor networks, cloud

computing

Page 4: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 4

Challenges for Concurrent Programming Large-Scale Distribution

Multiple, interacting components Example: Multimedia applications How to manage interaction of components?

Lack of scalability of current concurrent programming techniques: User level thread management Shared memory with locks, unlocks

Page 5: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 5

The Actor Model

ThreadState

Procedure

ThreadState

Procedure

ThreadState

Procedure

Interface

Interface

Interface

Messages

Page 6: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 6

Actors as concurrent objects

A distributed system is a collection of actors

An actor is an autonomous, interacting component of a distributed system.

An actor has: an immutable identity

(name, virtual address) a mutable local state procedures to manipulate

local state a thread of control

Thread State

Procedure

Page 7: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 7

The Actor Model: Fundamentals An actor may:

Process messages

send messages change local

state create new

actors

ThreadState

Procedure

ThreadState

Procedure

ThreadState

Procedure

Interface

Interface

Interface

Messages

Page 8: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 8

Arrival Order Nondeterminism

Communication is asynchronous

Page 9: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 9

Java’s Concurrency Model

Page 10: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 10

Naming in Java and Actors

Java: Cannot uniquely refer to objects worldwide Restriction on migration

Actors: A mail address represents an actor’s locality in a virtual

computational space Use of a mail address independent of actor implementation

provides actors with location transparency

Page 11: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 11

Programming in Actors

Coarse grained versus fine-grained Actors Advantage of fine-grained actors:

Can “over-decompose” application into actors As the number of cores increase, distribute the

actors Speed-up is constrained only by parallelism

in algorithm Retain parallelism inherent in the application

Page 12: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 12

Programming Abstractions for Actors High-level language constructs capture

patterns of use Simplify expression of parallelism Facilitate optimizations through compiler and

runtime Support a separation of design concerns

Example of common high level language constructs Local synchronization constraints Call-reply communication

Page 13: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 13

Local Synchronization Constraints

• Sender may not be in a state where it can process a message. Example: disable get( ) when empty (buffer)

Page 14: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 14

Request Reply Communication

Page 15: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 15

Join Continuation Transformation

Translation to basic actor semantics Can be automated

Avoids context-switching costs in implementations If the state of A depends on replies, transform to continuation

method

Page 16: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 16

Concurrent Call/Return Communication in the Thal CompilerCreates join continuation closure (JCC): 4 components 1. counter number of empty slots 2. function invoked with JCC as argument 3. creator 4. argument slots Minimize switching cost using dataflow analysis

only necessary context is in JCC General transformation framework

identify set of mutually independent request expressions across statement boundary.

Page 17: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 17

Two Approaches to Implementing Actors Programming Language

Pre-processor Compiler Interpreter

Libraries

Page 18: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 18

Language Approach

Enforces actor semantics High-level abstractions for expressiveness Program transformations to achieve

efficiency Close interaction of compiler and run-time

system Examples: Rosette, THAL, SALSA, …

Page 19: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 19

Actor Languages

Act1, Act2, Act3 (MIT): Lisp like syntax.. Rosette (MCC): scripting language Erlang: used for web services, telecom E-on-Lisp, E-on-Java: used for P2P systems SALSA (UIUC/RPI), THAL (UIUC): used in scientific

computing Ptolemy (UCB): used for real-time systems ActorNet (UIUC): sensor networks

Page 20: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 20

Library Approach

ActorFoundry, AA: Java Libraries ActTalk: Smalltalk Act++, Broadway: C++ Kilim

Page 21: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 21

ActorFoundry

Java Library supporting Actor Semantics Universal naming Single threaded objects Asynchronous communication Simplified migration Fair message delivery

Page 22: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 22

Thal

A High-Level Actor Language Local synchronization constraints Request reply communication Actor groups (arrays, etc.) Programmer may control placement and migration of actors

Efficient compiler and runtime system All actors on a node share a single message queue Local messages transformed to function calls Join continuation transform to avoid context switches

Page 23: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 23

Example Thal Program: Bank accountsbehv CheckingAccount

| curr_bal |init (ib, io) curr_bal = ib;endmethod deposit (id, teller) curr_bal = curr_bal + id; teller <- show_balance (curr_bal);endmethod withdraw (iw, teller) if (iw > curr_bal) then

teller <- overdrawn (iw – curr_bal); else

curr_bal = curr_bal - iw;teller <- done (iw);

endendmethod balance (teller) teller <- show_balance (curr_bal);end

end

Main| checking, atm,… |…checking = CheckingAccount.new(100);checking <- deposit (200, atm);checking <- withdraw (150, atm);

end

Page 24: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 24

Owner computes semantics..

class Point { ... method compute () { myvalue = ((north.value()+ east.value() + west.value() + south.value())/4; self <- compute (); }} 5 point stencil Jacobi method with call/return

communication

Page 25: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 25

Dynamic Actor Placement

Communication cost relatively independent of proximity of nodes, but... Sustained bandwidth may vary depending on

network traffic Optimal placement:

harmonizes locality and load balance is application architecture specific

THAL uses on <location> modifier for create

Page 26: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 26

Thal Runtime Modules

Page 27: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 27

Separation of Concerns

Would like to design and program at the level of interaction between applications

Want to specify and program different concerns separately

basic functionality security dependability / availability real-time requirements

Page 28: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 28

Abstracting Interaction

How to express coordination modularly? Separate interaction policy from protocols used to

implement policy

Page 29: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 29

Problems OS provides only low level communication and

resource management Different languages have different representations

and interaction mechanisms Coordination of distributed components is

complex Assuring non-interference -- concurrently

executing `independent’ services may share resources -- bandwidth, cycles, memory information -- database, sensors/actuators

Page 30: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 30

Example: Auragen Primary Backup

Protocol Characteristics

1. independent of application

2. modifies communication

3. manipulates state

Page 31: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 31

Components of a Protocol Instance

Roles define an actors behavior in the protocol

Page 32: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 32

Transparent Implementation of ProtocolsReflection enables protocol implementations to be independent of

application implementations

A meta-level actor describes functionality of actor. To change the application’s behavior, modify the relevant meta-

actor: scheduler, communication system, memory

Page 33: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 33

Example: Real Time Constraints

Page 34: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 34

Applications

Customizable Protocols

Global SnapshotGlobal

Snapshot

Clock Synchronization

Clock Synchronization Contention

Resolution

Core Services

Actor 2 Actor 3

QoS Constraints

Periodic RT Constraint

Actor 1

ProtocolCustomization

Composable Core Services

Page 35: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 35

Research Directions

New programming language abstractions Real-time constraints Any-time computations

Run-time for multi-core Maintain constraints Optimize power consumption

Page 36: Actor-based Programming for Scalable Concurrent Systems

10/17/2008 Agha UPCRC Seminar 36

References

1. Gul Agha, “Concurrent object-oriented programming,” Communications of the ACM, Volume 33 Issue 9, September 1990.

2. WooYoung Kim and Gul Agha, “Efficient Support of Location Transparency in Concurrent Object-Oriented Programming Languages,” ACM Supercomputing, 1995.

3. Mark Astley, Daniel C. Sturman, and Gul Agha, “Customizable middleware for modular distributed software,” Communications of the ACM, Volume 44(5), pp 99-107, ACM 2001.

4. Carlos A. Varela, Gul Agha. "Programming Dynamically Reconfigurable Open Systems with SALSA," 16th Annual ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications: Intriguing Technology Track, 2001, SIGPLAN Notices, vol. 36, pp20-34, ACM.

5. Nalini Venkatasubramanian, Carolyn L. Talcott, Gul Agha, “A Formal Model for Reasoning about Adaptive Qos-Enabled Middleware.” ACM Transactions Software Engineering Methodology, Volume 13(1), pp 86-147, ACM 2004.

6. Po-Hao Chang, Gul Agha, “Towards Context-Aware Web Applications,” Proceedings of the 7th IFIP International Conference on Distributed Applications and Interoperable Systems (DAIS 2007), Lecture Notes in Computer Science, volume 4531, pp 239-252, Springer, 2007.