jvm independent replay in java
play

JVM Independent Replay in Java RV04 April 3, 2004, Barcelona, Spain - PowerPoint PPT Presentation

JVM Independent Replay in Java RV04 April 3, 2004, Barcelona, Spain Viktor Schuppan , Marcel Baur, Armin Biere Computer Systems Institute, ETH Z urich http://www.inf.ethz.ch/schuppan/ 2004 V. Schuppan Computer Systems


  1. JVM Independent Replay in Java RV’04 – April 3, 2004, Barcelona, Spain Viktor Schuppan , Marcel Baur, Armin Biere Computer Systems Institute, ETH Z¨ urich http://www.inf.ethz.ch/˜schuppan/ � 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ c urich.

  2. Introduction 1 How am I supposed to find that bug? What kind of test GUI is that? tool static multi−threaded execution Java program checker trace J. User dynamic Why write checker another browser? custom browser P. Developer � 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ c urich.

  3. Introduction 2 test tool T0 static multi−threaded trace Java program checker description T1 compliant T2 replayer dynamic debugger checker T1 time deterministic execution → Tool users work in familiar debugging environment → Tool developers focus on trace generation Approach: bytecode instrumentation � 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ c urich.

  4. Contents 3 1. Introduction 2. Trace Description 3. Results 4. Conclusion � 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ c urich.

  5. Replay – Content-based Approach 4 Directly restore results of shared memory reads p c1 c2 buf cnt cnt replay data cnt buf buf cnt [e.g. Pan, Linton 1988] � 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ c urich.

  6. Replay – Ordering-based Approaches 1 5 Restore partial order of shared memory accesses p c1 c2 buf cnt cnt replay cnt data buf buf cnt directly restore order [e.g. LeBlanc, Mellor-Crummey 1987] � 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ c urich.

  7. Replay – Ordering-based Approaches 2 6 Restore partial order of shared memory accesses p c1 c2 buf cnt cnt cnt replay data buf buf cnt restore thread switches [e.g. Russinovich, Cogswell 1996] � 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ c urich.

  8. Replay – Comparison of Approaches 7 m s s e c i z l i e i e t s n r l y l u a e a a t m c r l p p a a a e e p r c s t r content− − + − − − based ordering−based direct + + o/ + o o/ + order thread + o / − + + o switches � 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ c urich.

  9. Replay – Comparison of Approaches 8 m s s e c z i l i e i e t s n r l y u l a e a a t m c r l p p a a a e e p r c s t r content− − + − − − based ordering−based direct + + o/ + o o/ + order thread + o / − + + o switches � 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ c urich.

  10. Specifying Points in an Execution – Example 9 Example: for (i = 0; i < 3; i++) { if (i % 2 == 0) { shared++; } { shared*=2; } else } unroll: i = 0; if (i < 3) { if (i % 2 == 0) { shared++; } } i++; if (i < 3) { if (i % 2 == 0) { shared*=2; } } else i++; if (i < 3) { if (i % 2 == 0) { /* replayer action */ shared++; } } i++; � 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ c urich.

  11. Specifying Points in an Execution – 1 10 Software instruction counter [Mellor-Crummey, LeBlanc 1989] (thread id, instruction, #backjumps) capture: count backjumps replay: count backjumps → less work for capture Count specific instructions (thread id, instruction, #executions) capture: count each instruction replay: count specific instructions → less work for replay → like debugger breakpoint � 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ c urich.

  12. Specifying Points in an Execution – 1 11 Software instruction counter [Mellor-Crummey, LeBlanc 1989] (thread id, instruction, #backjumps) capture: count backjumps replay: count backjumps → less work for capture Count specific instructions (thread id, instruction, #executions) capture: count each instruction replay: count specific instructions → less work for replay → like debugger breakpoint � 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ c urich.

  13. Specifying Points in an Execution – 2 12 after → trace: handle easily → instrument before successors → more natural? before → trace: may need to guess for last instruction → instrument before instruction → typically no difference in VM � 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ c urich.

  14. Specifying Points in an Execution – 2 13 after → trace: handle easily → instrument before successors → more natural? before → trace: may need to guess for last instruction → instrument before instruction → typically no difference in VM � 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ c urich.

  15. Example – Producer/Consumer 14 // Producer Method void run() 0 goto 3 3 invokestatic notFull() # (incomplete) schedule 6 ifeq 3 # 9 iconst_0 # 1 (producer) running 10 invokestatic put(int) before Producer 1 13 1 13 goto 3 switch 2 # c1 before Consumer 1 9 1 // Consumer switch 3 # c2 Method void run() before Consumer 1 13 1 0 goto 3 switch 2 # c1 3 invokestatic notEmpty() # error executing get 6 ifeq 3 9 invokestatic get() 12 istore_1 13 goto 3 � 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ c urich.

  16. Syntax 15 Events When should an action occur? true just before specified point in execution before true when in wait , sleep , join at specified point in Actions What action should occur? switch thread switch notify thread notify time-out thread timeout wait for termination and switch thread die terminate replay terminate log message log Execute finite or infinite loop in schedule Control flow start loop loopbegin end loop loopend � 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ c urich.

  17. Notes on Implementation 16 Approach • criteria: portability, maintenance, features • choices: modify VM, use standard interface, instrument code Places to instrument • given by schedule and • thread state related events Mechanics • use wait / notify to block/unblock a thread → get proper handling of (recursive) locks for free • track thread state separately � 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ c urich.

  18. block and unblock 17 public void block() throws Exception { synchronized (lock) { while (blocked) { try {lock.wait();} catch (InterruptedException e) {/* report error */} } blocked = true ; } } // block public void unblock() { synchronized (lock) { blocked = false ; lock.notifyAll(); } } // unblock � 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ c urich.

  19. Results 18 Portable replay • on Sun’s VMs 1.3/1.4, Jikes, Kaffe, Kissme • debugging with jdb, Eclipse, JDebugTool, and JSwat • Java thread model? → interrupt ed thread consumes notify ? Overhead • slowdown (Sun VM 1.4) typically < 10 times • +7 instructions at each instrumented location Capture • use JNuke to capture benchmark runs • implement listener for JPF with ∼ 250 loc as a matter of 1 – 2 days � 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ c urich.

  20. The End 19 Conclusions Suggest to use debuggers to browse traces generated by checkers Propose format to describe multi-threaded execution traces Show feasibility of portable replay Thanks. � 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ c urich.

  21. Backup-Slides 20 Keep out! Backup slides � 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ c urich.

  22. JReplay 21 .class JNuke replay VM engine before Class 1 0 1 T0 switch 1 in Class 2 1 1 switch 2 compliant T1 static in Class 1 2 1 modified notify 1 jreplay VM/ checker .class switch 1 T2 before Class 2 1 1 debugger terminate T1 t dynamic checker deterministic schedule execution � 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ c urich.

  23. Thread Model 22 (reacquire lock), reschedule/set interrupted flag (reacquire lock), reschedule/throw InterruptedException (reacquire lock), reschedule w.notified notify interrupt w. int. flag notify throw InterruptedException interrupt waiting w. int. throw r. interrupted interrupt notify time−out wait,join,sleep/ w. timed−out wait interrupted run.return interrupt j. joined new Thread() died interrupt j. int. flag died start join interrupt existing running joining j. int. throw interrupt time−out j. timed−out run.return sleep s. int. throw interrupt sleeping s. int. flag interrupt dead time−out s. timed−out � 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ c urich.

  24. Performance – Overhead 23 40 30 Sun 1.4 Sun 1.3 20 Jikes Kaffe Sable 10 0 Barrier Sync LUFact Crypt SOR SMM � 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ c urich.

Recommend


More recommend