Presentation is loading. Please wait.

Presentation is loading. Please wait.

Actor-based Programming for Scalable Concurrent Systems Gul Agha

Similar presentations


Presentation on theme: "Actor-based Programming for Scalable Concurrent Systems Gul Agha"— Presentation transcript:

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

2 10/17/2008 Agha UPCRC Seminar 2 Outline Defining the actor model High-level actor programming languages Implementing actors Orchestrating large numbers of actors

3 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

4 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

5 10/17/2008 Agha UPCRC Seminar 5 The Actor Model Thread State Procedure Thread State Procedure Thread State Procedure Interface Messages

6 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

7 10/17/2008 Agha UPCRC Seminar 7 The Actor Model: Fundamentals An actor may:  Process messages  send messages  change local state  create new actors Thread State Procedure Thread State Procedure Thread State Procedure Interface Messages

8 10/17/2008 Agha UPCRC Seminar 8 Arrival Order Nondeterminism Communication is asynchronous

9 10/17/2008 Agha UPCRC Seminar 9 Java’s Concurrency Model

10 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

11 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

12 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

13 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)

14 10/17/2008 Agha UPCRC Seminar 14 Request Reply Communication

15 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

16 10/17/2008 Agha UPCRC Seminar 16 Concurrent Call/Return Communication in the Thal Compiler Creates 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.

17 10/17/2008 Agha UPCRC Seminar 17 Two Approaches to Implementing Actors Programming Language  Pre-processor  Compiler  Interpreter Libraries

18 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, …

19 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

20 10/17/2008 Agha UPCRC Seminar 20 Library Approach ActorFoundry, AA: Java Libraries ActTalk: Smalltalk Act++, Broadway: C++ Kilim

21 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

22 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

23 10/17/2008 Agha UPCRC Seminar 23 Example Thal Program: Bank accounts behv CheckingAccount | curr_bal | init (ib, io) curr_bal = ib; end method deposit (id, teller) curr_bal = curr_bal + id; teller <- show_balance (curr_bal); end method withdraw (iw, teller) if (iw > curr_bal) then teller <- overdrawn (iw – curr_bal); else curr_bal = curr_bal - iw; teller <- done (iw); end method balance (teller) teller <- show_balance (curr_bal); end Main | checking, atm,… | … checking = CheckingAccount.new(100); checking <- deposit (200, atm); checking <- withdraw (150, atm); end

24 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

25 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 modifier for create

26 10/17/2008 Agha UPCRC Seminar 26 Thal Runtime Modules

27 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

28 10/17/2008 Agha UPCRC Seminar 28 Abstracting Interaction How to express coordination modularly? Separate interaction policy from protocols used to implement policy

29 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

30 10/17/2008 Agha UPCRC Seminar 30 Example: Auragen Primary Backup Protocol Characteristics 1.independent of application 2.modifies communication 3.manipulates state

31 10/17/2008 Agha UPCRC Seminar 31 Components of a Protocol Instance Roles define an actors behavior in the protocol

32 10/17/2008 Agha UPCRC Seminar 32 Transparent Implementation of Protocols Reflection 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

33 10/17/2008 Agha UPCRC Seminar 33 Example: Real Time Constraints

34 10/17/2008 Agha UPCRC Seminar 34 Applications Customizable Protocols Global Snapshot Global Snapshot Clock Synchronization Clock Synchronization Contention Resolution Core Services Actor 2 Actor 3 QoS Constraints Periodic RT Constraint Actor 1 Protocol Customization Composable Core Services

35 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

36 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.Concurrent object-oriented programming 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.


Download ppt "Actor-based Programming for Scalable Concurrent Systems Gul Agha"

Similar presentations


Ads by Google