CAF - The C++ Actor Framework for Scalable and Resource-e ffi cient - - PowerPoint PPT Presentation

caf the c actor framework for scalable and resource e ffi
SMART_READER_LITE
LIVE PREVIEW

CAF - The C++ Actor Framework for Scalable and Resource-e ffi cient - - PowerPoint PPT Presentation

CAF - The C++ Actor Framework for Scalable and Resource-e ffi cient Applications Dominik Charousset, Raphael Hiesgen, and Thomas C. Schmidt {dominik.charousset,raphael.hiesgen,t.schmidt}@haw-hamburg.de Dept. Computer Science Hamburg University


slide-1
SLIDE 1

CAF - The C++ Actor Framework for Scalable and Resource-efficient Applications

Dominik Charousset, Raphael Hiesgen, and Thomas C. Schmidt

{dominik.charousset,raphael.hiesgen,t.schmidt}@haw-hamburg.de

  • Dept. Computer Science

Hamburg University of Applied Sciences Germany

October 2014, AGERE!@SPLASH

slide-2
SLIDE 2

Previous Work

Implemented native actor library libcppa actor library in C++

Target at both high-performance and embedded environments Allow millions of lightweight actors

Extended the actor model with publish/subscribe semantics

Original actor model only foresees 1:1 communication Internet scale requires loose coupling

Support heterogeneous hardware components

GPUs can outperform CPUs by orders of magnitude Transparent integration of OpenCL allows flexible deployment

Dominik Charousset iNET – HAW Hamburg 2

slide-3
SLIDE 3

Rebranding & Modularization

Our approach to a growing userbase with diverse requirements: Move from a monolithic library to an open framework Split functionality into (optional) modules Enable customization via extensible framework structure Central project homepage1 linking to all activities

1http://actor-framework.org Dominik Charousset iNET – HAW Hamburg 3

slide-4
SLIDE 4

Agenda

1 Type-safe Message Passing 2 Scheduling Infrastructure 3 Runtime Inspection & Debugging 4 Conclusion & Outlook

Dominik Charousset iNET – HAW Hamburg 4

slide-5
SLIDE 5

Agenda

1 Type-safe Message Passing 2 Scheduling Infrastructure 3 Runtime Inspection & Debugging 4 Conclusion & Outlook

Dominik Charousset iNET – HAW Hamburg 5

slide-6
SLIDE 6

Problem of Dynamic Typing

The original model2 defines actors in terms of (Untyped) message passing primitives Pattern matching ⇒ Extensive integration testing required

Coding errors occur at runtime Non-local dependencies are hard to track manually

2Carl Hewitt, Peter Bishop, and Richard Steiger. A Universal Modular ACTOR Formalism for Artificial Intelligence. In Proceedings of the 3rd IJCAI, pages 235–245, San Francisco, CA, USA, 1973. Morgan Kaufmann Publishers Inc. Dominik Charousset iNET – HAW Hamburg 6

slide-7
SLIDE 7

Type-safe Message Passing

Lift type system of C++ and make it applicable to actor interfaces Compiler statically checks protocols between actors Protocol violation cannot occur at runtime Compiler verifies both incoming and outgoing messages:

using math = typed_actor < replies_to <int , int >::with <int >, replies_to <float >::with <float , float >>; // ... auto ms = typed_spawn (...); sync_send(ms , 10, 20). then( []( float result) { // compiler error: result is int , not float } );

Dominik Charousset iNET – HAW Hamburg 7

slide-8
SLIDE 8

Agenda

1 Type-safe Message Passing 2 Scheduling Infrastructure 3 Runtime Inspection & Debugging 4 Conclusion & Outlook

Dominik Charousset iNET – HAW Hamburg 8

slide-9
SLIDE 9

Scalability of Scheduling

CAF aims at scaling to millions of actors on hundreds of processors Actors cannot be implemented (efficiently) as threads Running in userspace prohibits preemption Classical thread pool or centralized scheduler has limitations

Central job queue is a bottleneck per se Short-lived tasks cause significant runtime overhead Could schedule actors for real-time with a priori knowledge 3

3M.L. Dertouzos and AK. Mok. Multiprocessor Online Scheduling of Hard-Real-Time Tasks. Software Engineering, IEEE Transactions on, 15(12):1497–1506, Dec 1989 Dominik Charousset iNET – HAW Hamburg 9

slide-10
SLIDE 10

Centralized Scheduling Issue

Divide & conquer: 220 actors with libcppa (central scheduling, 2013)

2 4 6 8 10 12 5 10 15 20 25 Time [s] Number of Cores [#] libcppa scala erlang

libcppa reached maximum performance

  • n 8 cores for divide & conquer algorithms

Dominik Charousset iNET – HAW Hamburg 10

slide-11
SLIDE 11

Scheduling Approaches

Active dispatching

Central task management One (or more) threads manage others High communication overhead

Shared work queues

Reactive task management Workers access one (or more) shared queues Frequent access to shared data is a likely performance bottleneck

Individual work queues

Decentralized, reactive task management Workers communicate only when idle Minimizes synchronizations between threads

Dominik Charousset iNET – HAW Hamburg 11

slide-12
SLIDE 12

Work Stealing

Decentralized scheduling using Work Stealing4 One job queue and worker per core Worker tries stealing work items from others when idle Stealing is a rare event for most work loads5 But: A priori knowledge cannot be exploited (no global view)

4Robert D. Blumofe and Charles E. Leiserson. Scheduling Multithreaded Computations by Work Stealing.

  • J. ACM, 46(5):720–748, September 1999.

5Vivek Kumar, Daniel Frampton, Stephen M. Blackburn, David Grove, and Olivier Tardieu. Work-stealing Without the Baggage. In Proceedings of the ACM International Conference on Object Oriented Programming Systems Languages and Applications, OOPSLA ’12, pages 297–314, New York, NY, USA, 2012. ACM. Dominik Charousset iNET – HAW Hamburg 12

slide-13
SLIDE 13

Work Stealing

Victim

Worker 1

Thief

Worker 2 Worker P

Queue 1 Queue 2 Queue P

Job 1 Job 2 Job 3 … Job N Job 3

S t e a l Dominik Charousset iNET – HAW Hamburg 13

slide-14
SLIDE 14

Configurable Scheduling in CAF

Framework has no a priori knowledge → Work Stealing as default Using Work Stealing, CAF scales up to at least 64 cores Developers can deploy custom scheduler using

template <class Policy = work_stealing > void set_scheduler (size_t num_workers = ..., size_t max_msgs = indefinite ); max_msgs restricts # of messages actors can consume at once

Low value increases fairness and avoids bursts High value minimizes queue access, usually maximizing throughput

Policy can be implemented to exploit a priori knowledge, if possible

Dominik Charousset iNET – HAW Hamburg 14

slide-15
SLIDE 15

Scheduling Infrastructure

Divide & conquer: 220 actors with CAF

4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 5 10 15 20 25

ActorFoundry CAF Charm Erlang Scala

Time [s] Number of Cores [#]

Dominik Charousset iNET – HAW Hamburg 15

slide-16
SLIDE 16

Scheduling Infrastructure

Mixed operations under work load with CAF

4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 50 100 150 200 250 300 350

ActorFoundry CAF Charm Erlang Scala

Time [s] Number of Cores [#]

Dominik Charousset iNET – HAW Hamburg 16

slide-17
SLIDE 17

Agenda

1 Type-safe Message Passing 2 Scheduling Infrastructure 3 Runtime Inspection & Debugging 4 Conclusion & Outlook

Dominik Charousset iNET – HAW Hamburg 17

slide-18
SLIDE 18

Runtime Inspection & Debugging

Debugging of distributed systems is inherently complex

Non-trivial program flow No global clock Diverging states

Recording messages crucial for on-line or post-mortem debugging Erroneous behavior can be reproduced using message replaying 6 Visualization tools can help understanding complex errors 7

6Dennis Michael Geels, Gautam Altekar, Scott Shenker, and Ion Stoica. Replay debugging for distributed applications. In Proc. of USENIX’06 Ann. Tech. Conf., pages 289–300. USENIX Assoc., 2006. 7Terry Stanley, Tyler Close, and Mark S Miller. Causeway: A message-oriented distributed debugger. Technical Report HPL-2009-78, HP Laboratories, 2009. Dominik Charousset iNET – HAW Hamburg 18

slide-19
SLIDE 19

Runtime Inspection & Debugging

Nexus Frontend (e.g. shell) Node A P1 … … Node N PN

actor A actor B actor C actor D

Dominik Charousset iNET – HAW Hamburg 19

slide-20
SLIDE 20

Runtime Inspection & Debugging

Nexus Frontend (e.g. shell) Node A P1 … … Node N PN

actor A actor B actor C actor D

Dominik Charousset iNET – HAW Hamburg 20

slide-21
SLIDE 21

Runtime Inspection & Debugging

Nexus Frontend (e.g. shell) Node A P1 … … Node N PN

actor A actor B actor C actor D

P1 … PN

Probes Intercept & forward three kinds of messages to the Nexus:

Activity events: incoming & outgoing messages Error events: network & system failures Runtime statistics: periodic collection of CPU load, etc.

Dominik Charousset iNET – HAW Hamburg 21

slide-22
SLIDE 22

Runtime Inspection & Debugging

Nexus Frontend (e.g. shell) Node A P1 … … Node N PN

actor A actor B actor C actor D

Nexus

The Nexus Provides global view of the distributed system Receives & collects events from Probes Statefully configures verbosity of Probes

Dominik Charousset iNET – HAW Hamburg 22

slide-23
SLIDE 23

Runtime Inspection & Debugging

Nexus Frontend (e.g. shell) Node A P1 … … Node N PN

actor A actor B actor C actor D

Frontend (e.g. shell)

Frontend application categories Observing agents: monitoring & threshold-based alerts Supervising agents: active manipulation of running app. Monitoring & visualization: access to aggregate state

⇒ For instance, an interactive inspection shell

Dominik Charousset iNET – HAW Hamburg 23

slide-24
SLIDE 24

Interactive Inspection Shell

Allows users to inspect distributed system In global mode:

Global view to the system Access to individual participating nodes

In node mode:

Access to statistics such as RAM usage, CPU load, etc. Direct interaction with actors on that node

Dominik Charousset iNET – HAW Hamburg 24

slide-25
SLIDE 25

Agenda

1 Type-safe Message Passing 2 Scheduling Infrastructure 3 Runtime Inspection & Debugging 4 Conclusion & Outlook

Dominik Charousset iNET – HAW Hamburg 25

slide-26
SLIDE 26

Conclusion

CAF is a robust, scalable platform for native actor programming Strong emphasis on low mem. footprint and performance Type-safe messaging interfaces Open scheduling infrastructure with efficient default First step towards debugging distributed actors

Dominik Charousset iNET – HAW Hamburg 26

slide-27
SLIDE 27

Outlook

Scale down to IoT devices (port CAF to RIOT-OS8) Load balancing for massively parallel, distributed systems Monitoring and debugging tools based on current platform Robust security layer for the IoT: subsuming strong authentication

  • f actors in combination with opportunistic encryption

8http://riot-os.org Dominik Charousset iNET – HAW Hamburg 27

slide-28
SLIDE 28

Thank you for your attention!

Homepage: http://actor-framework.org Sources: https://github.com/actor-framework iNET Working Group: http://inet.cpt.haw-hamburg.de

Dominik Charousset iNET – HAW Hamburg 28

slide-29
SLIDE 29

References

Carl Hewitt, Peter Bishop, and Richard Steiger. A Universal Modular ACTOR Formalism for Artificial Intelligence. In Proceedings of the 3rd IJCAI, pages 235–245, San Francisco, CA, USA, 1973. Morgan Kaufmann Publishers Inc. M.L. Dertouzos and AK. Mok. Multiprocessor Online Scheduling of Hard-Real-Time Tasks. Software Engineering, IEEE Transactions on, 15(12):1497–1506, Dec 1989. Robert D. Blumofe and Charles E. Leiserson. Scheduling Multithreaded Computations by Work Stealing.

  • J. ACM, 46(5):720–748, September 1999.

Vivek Kumar, Daniel Frampton, Stephen M. Blackburn, David Grove, and Olivier Tardieu. Work-stealing Without the Baggage. In Proceedings of the ACM International Conference on Object Oriented Programming Systems Languages and Applications, OOPSLA ’12, pages 297–314, New York, NY, USA, 2012. ACM. Dennis Michael Geels, Gautam Altekar, Scott Shenker, and Ion Stoica. Replay debugging for distributed applications. In Proc. of USENIX’06 Ann. Tech. Conf., pages 289–300. USENIX Assoc., 2006. Terry Stanley, Tyler Close, and Mark S Miller. Causeway: A message-oriented distributed debugger. Technical Report HPL-2009-78, HP Laboratories, 2009.

Dominik Charousset iNET – HAW Hamburg 29