Incremental Checkpointing with Application to Distributed Discrete Event Simulation Thomas Huining Feng and Edward A. Lee {tfeng,

Slides:



Advertisements
Similar presentations
Chapt.2 Machine Architecture Impact of languages –Support – faster, more secure Primitive Operations –e.g. nested subroutine calls »Subroutines implemented.
Advertisements

MapReduce Online Created by: Rajesh Gadipuuri Modified by: Ying Lu.
Problem Solving 5 Using Java API for Searching and Sorting Applications ICS-201 Introduction to Computing II Semester 071.
Stacks Chapter 11.
Parallel and Distributed Simulation Time Warp: Basic Algorithm.
Rule Based Operational Semantics Specification in Ptolemy Yanwar Asrigo COMP 763B - Modeling and Simulation Based Design 30 th April 2008.
A code generator for the CAL actor language Lars Wernli Supervisor: Joern Janneck, UC Berkeley Professor: Lothar Thiele, ETH Zuerich.
1 PtHOMAS project, Ptolemy mini-conference '09 CR/RTC3-NA Elizabeth Latronico; UC Berkeley Jackie Mankit Leung | 4/16/2009 | © 2009 Robert Bosch LLC and.
PTIDES: Programming Temporally Integrated Distributed Embedded Systems Yang Zhao, EECS, UC Berkeley Edward A. Lee, EECS, UC Berkeley Jie Liu, Microsoft.
Intermediate code generation. Code Generation Create linear representation of program Result can be machine code, assembly code, code for an abstract.
Component Technologies for Embedded Systems Johan Eker.
Chess Review May 8, 2003 Berkeley, CA Classes and Inheritance in Actor- Oriented Models Stephen Neuendorffer Edward Lee UC Berkeley.
5 th Biennial Ptolemy Miniconference Berkeley, CA, May 9, 2003 Java Code Generation Steve Neuendorffer UC Berkeley.
Type System, March 12, Data Types and Behavioral Types Yuhong Xiong Edward A. Lee Department of Electrical Engineering and Computer Sciences University.
7th Biennial Ptolemy Miniconference Berkeley, CA February 13, 2007 Leveraging Synchronous Language Principles for Hybrid System Models Haiyang Zheng and.
Backtracking for Distributed Model Execution Refactoring Preview Batch Refactoring Actions and Settings Ptolemy Editor Backtracking Motivation – Distributed.
CS 290C: Formal Models for Web Software Lecture 10: Language Based Modeling and Analysis of Navigation Errors Instructor: Tevfik Bultan.
February 11, 2010 Center for Hybrid and Embedded Software Systems Ptolemy II - Heterogeneous Concurrent Modeling and Design.
Money Networks Manage your money with synchronous-reactive money networks. By Adam Cataldo.
February 12, 2009 Center for Hybrid and Embedded Software Systems Encapsulated Model Transformation Rule A transformation.
Mixing Models of Computation Jie Liu Palo Alto Research Center (PARC) 3333 Coyote Hill Rd., Palo Alto, CA joint work with Prof. Edward.
Design of Fault Tolerant Data Flow in Ptolemy II Mark McKelvin EE290 N, Fall 2004 Final Project.
Chess Review November 21, 2005 Berkeley, CA Edited and presented by Causality Interfaces and Compositional Causality Analysis Rachel Zhou UC Berkeley.
Heterochronous Dataflow in Ptolemy II Brian K. Vogel EE249 Project Presentation, Dec. 4, 1999.
SEC PI Meeting Annapolis, May 8-9, 2001 Component-Based Design of Embedded Control Systems Edward A. Lee & Jie Liu UC Berkeley with thanks to the entire.
Department of Electrical Engineering and Computer Sciences University of California at Berkeley System-Level Types for Component-Based Design Edward A.
Department of Electrical Engineering and Computer Sciences University of California at Berkeley Concurrent Component Patterns, Models of Computation, and.
February 12, 2009 Center for Hybrid and Embedded Software Systems Model Transformation Using ERG Controller Thomas H. Feng.
MoBIES Working group meeting, September 2001, Dearborn Ptolemy II The automotive challenge problems version 4.1 Johan Eker Edward Lee with thanks.
7th Biennial Ptolemy Miniconference Berkeley, CA February 13, 2007 PTIDES: A Programming Model for Time- Synchronized Distributed Real-time Systems Yang.
5 th Biennial Ptolemy Miniconference Berkeley, CA, May 9, 2003 JHDL Hardware Generation Mike Wirthlin and Matthew Koecher
Designing Predictable and Robust Systems Tom Henzinger UC Berkeley and EPFL.
MOBIES Project Progress Report Engine Throttle Controller Design Using Multiple Models of Computation Edward Lee Haiyang Zheng with thanks to Ptolemy Group.
System-Level Types for Component-Based Design Paper by: Edward A. Lee and Yuhong Xiong Presentation by: Dan Patterson.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
OOP Languages: Java vs C++
Course Outline DayContents Day 1 Introduction Motivation, definitions, properties of embedded systems, outline of the current course How to specify embedded.
Fundamentals of Python: From First Programs Through Data Structures Chapter 14 Linear Collections: Stacks.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
Mathematical Modeling and Formal Specification Languages CIS 376 Bruce R. Maxim UM-Dearborn.
CMSC 202 Exceptions. Aug 7, Error Handling In the ideal world, all errors would occur when your code is compiled. That won’t happen. Errors which.
Programming Languages and Paradigms Object-Oriented Programming (Part II)
1 Object Oriented Programming Lecture IX Some notes on Java Performance with aspects on execution time and memory consumption.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
Constructors CMSC 202. Object Creation Objects are created by using the operator new in statements such as… The following expression invokes a special.
The 14 th IEEE Real-Time and Embedded Technology and Applications Symposium, April 2008 Real-Time Distributed Discrete-Event Execution with Fault Tolerance.
Today’s Agenda  Generic  Iterators CS2336: Computer Science II.
Lecture 3 Classes, Structs, Enums Passing by reference and value Arrays.
Actor Oriented Programming with CAL -designing embedded system components Johan Eker Department of Automatic Control, Lund University Chris Chang, Jörn.
 2008 Pearson Education, Inc. All rights reserved. 1 Arrays and Vectors.
CMSC 202 Advanced Section Classes and Objects: Object Creation and Constructors.
1 Data Structures CSCI 132, Spring 2014 Lecture 33 Hash Tables.
Linking FMI-based Components with Ptolemy II’s Discrete Event Domain Introduction In the simulation of cyber-physical systems, event driven models with.
Session 7 More Implications of Inheritance & Chapter 5: Ball World Example.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
Objects First with Java Creating cooperating objects
Ptolemy II - Heterogeneous Concurrent Modeling and Design in Java
Chapter 2 Processes and Threads Today 2.1 Processes 2.2 Threads
Event Relation Graphs and Extensions in Ptolemy II
Ptolemy II - Heterogeneous Concurrent Modeling and Design in Java
Threads and Cooperation
Shanna-Shaye Forbes Ben Lickly Man-Kit Leung
Ptolemy II - Heterogeneous Concurrent Modeling and Design in Java
Ptolemy II - Heterogeneous Concurrent Modeling and Design in Java
Parallel and Distributed Simulation
Model Transformation with the Ptera Controller
CMSC 202 Exceptions.
Classes and Objects Object Creation
CMSC 202 Constructors Version 9/10.
Presentation transcript:

Incremental Checkpointing with Application to Distributed Discrete Event Simulation Thomas Huining Feng and Edward A. Lee {tfeng, CHESS Center for Hybrid and Embedded Software Systems EECS, UC Berkeley Winter Simulation Conference 2006 Monterey, CA December 3-6, 2006

T. H. Feng and E. A. Lee, UC Berkeley2 Outline Background: heterogeneous model simulation with Ptolemy II Problem: state recovery for backtracking Approach: automatic state recovery with incremental checkpointing Application: optimistic Time Warp simulation Conclusion

T. H. Feng and E. A. Lee, UC Berkeley3 Ptolemy II Background Hierarchical composition of actors. Ports connected with relations. The scheduler determines the semantics. Users may define actors in Java. class Select extends Actor { public boolean prefire() {…} public void fire() {…} public boolean postfire() {…} }

T. H. Feng and E. A. Lee, UC Berkeley4 Model State Situations requiring state recovery: e.g., optimistic Time Warp simulation (Jefferson 1985). A model’s run-time state: class Accumulator extends Actor { private int sum; Port input, output;... void fire() { int value = input.get(); sum = sum + value; output.send(0, sum); } Model’s State Scheduler’s State (schedule, queues, etc.) Actor1’s State Actor2’s State

T. H. Feng and E. A. Lee, UC Berkeley5 Problems of State Recovery (1) We could recover the sceduler’s state with a careful design of the simulation environment. But how to recover actors’ states? Provide programmers with a library of state saving/recovery functions. Complicated user interaction. Make assumptions on the states, and provide automatic recovery. Not flexible. Model’s State Scheduler’s State (schedule, queues, etc.) Actor1’s State Actor2’s State

T. H. Feng and E. A. Lee, UC Berkeley6 snapshot Problems of State Recovery (2) P1P2 The extra cost usually prevents us from creating as many checkpoints as we want. Domino effect:

T. H. Feng and E. A. Lee, UC Berkeley7 Our Approach to State Recovery Correctness can be proved easily. Incremental. Small constant cost for checkpoint creation.  Allow to create checkpoint whenever it may be needed. The program is slowed down gracefully.  Real-time property can be proved.

T. H. Feng and E. A. Lee, UC Berkeley8 Java Analysis and Transformation 1. Use an analyzer to identify the states in the Java code. 2. Use a transformer to modify the program. class Accumulator extends Actor { private int sum; Port input, output;... void fire() { int value = input.get(); sum = sum + value; output.send(0, sum); } state update class Accumulator extends Actor { private int sum; Port input, output;... void fire() { int value = input.get(); $ASSIGN$sum(sum + value); output.send(0, sum); }

T. H. Feng and E. A. Lee, UC Berkeley9 Simple Assignment Transformation For each Java class: $ASSIGN$sum first saves sum’s current value, and then performs the Java assignment. class Accumulator extends Actor { private int sum; Port input, output;... void fire() { int value = input.get(); sum = sum + value; output.send(0, sum); } class Accumulator extends Actor { private int sum; Port input, output;... void fire() { int value = input.get(); $ASSIGN$sum(sum + value); output.send(0, sum); } int $ASSIGN$sum(int v) {... // save current sum return sum = v; }

T. H. Feng and E. A. Lee, UC Berkeley10 Simulating Assignment with Function Assignments are expressions. Function call precisely simulates assignment. Inlining as a compiler optimization. class Accumulator extends Actor { private int sum; Port input, output;... void fire() { int value = input.get(); output.send(0, sum = sum + value); } class Accumulator extends Actor { private int sum; Port input, output;... void fire() { int value = input.get(); output.send(0, $ASSIGN$sum(sum + value)); } int $ASSIGN$sum(int v) {... // record sum return sum = v; }

T. H. Feng and E. A. Lee, UC Berkeley11 Operators that Update Operands $update$sum handles all the Java operators, including +=, -=, ++, --, etc. class Accumulator extends Actor { private int sum; Port input, output;... void fire() { value = input.get(); output.send(0, sum += value); } class Accumulator extends Actor { private int sum; Port input, output;... void fire() { value = input.get(); output.send(0, $UPDATE$sum(0, value)); } /* Simulate Java operators. int $UPDATE$sum(int type, int v) {... // record sum switch (type) { case 0: return sum += v; case 1: return sum -= v; case 2: return sum ++; // v ignored case 3: return sum --; case 4: return ++ sum; case 5: return -- sum;... default: return error(); }

T. H. Feng and E. A. Lee, UC Berkeley12 Array Operations class StringStack { private String[] array; private int index;... void push(String s) { array[index++] = s; } String pop() { return array[index--]; } void clean() { index = 0; array = new String[MAX]; } void copy(StringStack stack) { stack.array = (String[]) array.clone(); stack.index = index; } class StringStack { private String[] array; private int index;... void push(String s) { $ASSIGN$array($UPDATE$index(2, 0), s); } String pop() { return array[$UPDATE$index(3, 0)]; } void clean() { $ASSIGN$index(0); $ASSIGN$array(new String[MAX]); } void copy(StringStack stack) { stack.$ASSIGN$array( (String[]) array.clone()); stack.$ASSIGN$index(index); }... }

T. H. Feng and E. A. Lee, UC Berkeley13 Checkpoint Control To create a checkpoint: long handle = createCheckpoint(); To recover state: rollback(handle); To discard a checkpoint: discard(handle); Application to threaded systems, e.g., Ptolemy II: Hierarchical composition of (sub-)models. An actor does not directly reference other actors.

T. H. Feng and E. A. Lee, UC Berkeley14 Data Structure int handle1 = createCheckpoint(); $ASSIGN$x(2); // x = 2; $ASSIGN$x(3); // x = 3; $ASSIGN$y(0, 1, -1); // y[0][1] = -1; int handle2 = createCheckpoint(); $UPDATE$x(2, 0); // x++; $ASSIGN$y(1, 0, -1); // y[1][0] = -1; $ASSIGN$y(1, 1, 0); // y[1][1] = 0; $ASSIGN$y(0, new int[2]); // y[0] = new int[2]; rollback(handle1); id = 1 checkpoint id = 2 checkpoint prev_ptr record field = “x” value = 1 cp_ptr null prev_ptr record field = “y[0][1]” value = 0 cp_ptr null prev_ptr record field = “x” value = 3 cp_ptr prev_ptr record field = “y[1][0]” value = 0 cp_ptr prev_ptr record field = “y[1][1]” value = 1 cp_ptr prev_ptr record field = “y[0]” value = → cp_ptr [1, -1] y[0] x = 1, y =x = 2, y =x = 3, y = x = 4, y =

T. H. Feng and E. A. Lee, UC Berkeley15 Stateful Java Classes Hashtable, List, Random, Set, Stack, etc. 1. Get the source (Hashtable, Map, …) from Sun (alternatively, GCJ): 2. Apply the same transformation: java.util.Hashtable → ptolemy.backtrack.java.util.Hashtable 3. Fix references: import java.util.Hashtable; class A extends Actor { private Hashtable table;... } import ptolemy.backtrack.java.util.Hashtable; class A extends Actor { private Hashtable table;... } package java.util; class Hashtable implements Map {... }

T. H. Feng and E. A. Lee, UC Berkeley16 Use Case: Recoverable Model Execution A DE model that autonomously recovers from error

T. H. Feng and E. A. Lee, UC Berkeley17 Application to Time Warp Simulation On receiving an event: create a checkpoint and record the handle. Process the event. When inconsistency happens: Detect the event that caused this problem. Recover the state right before the event was processed. Re-process the events since that time in a better order.

T. H. Feng and E. A. Lee, UC Berkeley18 Development Environment

T. H. Feng and E. A. Lee, UC Berkeley19 Development Environment

T. H. Feng and E. A. Lee, UC Berkeley20 Conclusion Easily proved correct using operational semantics of the Java language. (Refer to the paper.) High-performance backtracking mechanism. Checkpoint creation incurs a small constant cost. Rollback and discard operations are linear in the updates. Precisely roll back to any execution point (assuming enough memory). Applicable to real-time systems by slowing them down gracefully. Proportional slowdown because of the constant extra cost per update.