1 / 36

Actor-based Programming for Scalable Concurrent Systems

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.

charis
Download Presentation

Actor-based Programming for Scalable Concurrent Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Outline • Defining the actor model • High-level actor programming languages • Implementing actors • Orchestrating large numbers of actors 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 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 Agha UPCRC Seminar

  5. The Actor Model State Interface Thread Interface Procedure State Thread Messages Procedure Interface State Thread Procedure 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 Agha UPCRC Seminar

  7. The Actor Model: Fundamentals • An actor may: • Process messages • send messages • change local state • create new actors State Thread State Interface Thread Procedure Interface Procedure Messages Interface State Thread Procedure Agha UPCRC Seminar

  8. Arrival Order Nondeterminism Communication is asynchronous Agha UPCRC Seminar

  9. Java’s Concurrency Model 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 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 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 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) Agha UPCRC Seminar

  14. Request Reply Communication 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 Agha UPCRC Seminar

  16. Concurrent Call/Return Communication in the Thal Compiler Creates join continuation closure (JCC): 4 components • counter ­ number of empty slots • function ­ invoked with JCC as argument • creator • 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. Agha UPCRC Seminar

  17. Two Approaches to Implementing Actors • Programming Language • Pre-processor • Compiler • Interpreter • Libraries 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, … 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 Agha UPCRC Seminar

  20. Library Approach • ActorFoundry, AA: Java Libraries • ActTalk: Smalltalk • Act++, Broadway: C++ • Kilim Agha UPCRC Seminar

  21. ActorFoundry Java Library supporting Actor Semantics • Universal naming • Single threaded objects • Asynchronous communication • Simplified migration • Fair message delivery 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 Agha UPCRC Seminar

  23. 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 end method 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 Example Thal Program: Bank accounts 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 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 Agha UPCRC Seminar

  26. Thal Runtime Modules 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 Agha UPCRC Seminar

  28. Abstracting Interaction • How to express coordination modularly? • Separate interaction policy from protocols used to implement policy 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 Agha UPCRC Seminar

  30. Example: Auragen Primary Backup • Protocol Characteristics • independent of application • modifies communication • manipulates state Agha UPCRC Seminar

  31. Components of a Protocol Instance • Roles define an actors behavior in the protocol 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 Agha UPCRC Seminar

  33. Example: Real Time Constraints Agha UPCRC Seminar

  34. Composable Core Services Customizable Protocols Clock Synchronization Global Snapshot Contention Resolution Protocol Customization CoreServices Periodic RT Constraint Actor 1 Actor2 Actor 3 QoS Constraints Applications 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 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. Agha UPCRC Seminar

More Related