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

jvm independent replay in java
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 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/

c 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ urich.
slide-2
SLIDE 2

Introduction

1

execution trace multi−threaded Java program custom browser

to find that bug? How am I supposed

  • J. User

What kind of GUI is that? another browser? Why write

  • P. Developer

test tool static checker dynamic checker

c 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ urich.
slide-3
SLIDE 3

Introduction

2

multi−threaded Java program debugger compliant execution deterministic

T2 T1 T0 T1 time

description trace test tool static checker dynamic checker replayer

→ Tool users work in familiar debugging environment → Tool developers focus on trace generation Approach: bytecode instrumentation

c 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ urich.
slide-4
SLIDE 4

Contents

3

  • 1. Introduction
  • 2. Trace Description
  • 3. Results
  • 4. Conclusion
c 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ urich.
slide-5
SLIDE 5

Replay – Content-based Approach

4

Directly restore results of shared memory reads

replay data

p c1 c2 buf buf cnt cnt cnt cnt buf

[e.g. Pan, Linton 1988]

c 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ urich.
slide-6
SLIDE 6

Replay – Ordering-based Approaches 1

5

Restore partial order of shared memory accesses

replay data

p c1 c2 buf cnt cnt buf cnt buf cnt

directly restore order [e.g. LeBlanc, Mellor-Crummey 1987]

c 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ urich.
slide-7
SLIDE 7

Replay – Ordering-based Approaches 2

6

Restore partial order of shared memory accesses

replay data

p c1 c2

buf cnt cnt buf buf cnt cnt

restore thread switches [e.g. Russinovich, Cogswell 1996]

c 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ urich.
slide-8
SLIDE 8

Replay – Comparison of Approaches

7

+

  • /

+

  • /

c a p t u r e r e p l a y

  • +

− +

s e m a n t i c s

− +

  • switches

thread based content− t r a c e s i z e p a r a l l e l i s m

  • rdering−based

− + + −

direct

  • rder

+ o /

c 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ urich.
slide-9
SLIDE 9

Replay – Comparison of Approaches

8

+

  • /

+

  • /

c a p t u r e r e p l a y

  • +

− +

s e m a n t i c s

− +

  • switches

thread based content− t r a c e s i z e p a r a l l e l i s m

  • rdering−based

− + + −

direct

  • rder

+ o /

c 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ urich.
slide-10
SLIDE 10

Specifying Points in an Execution – Example

9

Example:

for (i = 0; i < 3; i++) { if (i % 2 == 0) {shared++;} else

{shared*=2;} }

unroll:

i = 0; if (i < 3) { if (i % 2 == 0) {shared++;} } i++; if (i < 3) { if (i % 2 == 0) else

{shared*=2;} }

i++; if (i < 3) { if (i % 2 == 0) { /* replayer action */ shared++; } } i++;

c 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ urich.
slide-11
SLIDE 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

c 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ urich.
slide-12
SLIDE 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

c 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ urich.
slide-13
SLIDE 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

c 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ urich.
slide-14
SLIDE 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

c 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ urich.
slide-15
SLIDE 15

Example – Producer/Consumer

14

// Producer Method void run() 0 goto 3 3 invokestatic notFull() 6 ifeq 3 9 iconst_0 10 invokestatic put(int) 13 goto 3 // Consumer Method void run() 0 goto 3 3 invokestatic notEmpty() 6 ifeq 3 9 invokestatic get() 12 istore_1 13 goto 3 # (incomplete) schedule # # 1 (producer) running before Producer 1 13 1 switch 2 # c1 before Consumer 1 9 1 switch 3 # c2 before Consumer 1 13 1 switch 2 # c1 # error executing get

c 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ urich.
slide-16
SLIDE 16

Syntax

15

Events When should an action occur? before true just before specified point in execution in true when in wait, sleep, join at specified point Actions What action should occur? switch switch thread notify notify thread timeout time-out thread die wait for termination and switch thread terminate terminate replay log log message Control flow Execute finite or infinite loop in schedule loopbegin start loop loopend end loop

c 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ urich.
slide-17
SLIDE 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
c 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ urich.
slide-18
SLIDE 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

c 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ urich.
slide-19
SLIDE 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?

→ interrupted 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
c 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ urich.
slide-20
SLIDE 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.

c 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ urich.
slide-21
SLIDE 21

Backup-Slides

20

Keep out! Backup slides

c 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ urich.
slide-22
SLIDE 22

JReplay

21 modified .class replay engine .class jreplay compliant

T0 T1 T2 t T1

VM/ debugger schedule deterministic execution

before Class 1 0 1 switch 1 in Class 2 1 1 switch 2 in Class 1 2 1 terminate switch 1 notify 1 before Class 2 1 1

JNuke static checker dynamic checker VM

c 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ urich.
slide-23
SLIDE 23

Thread Model

22

  • j. joined

waiting

  • w. timed−out
  • j. timed−out

joining

interrupt time−out join interrupt time−out notify wait interrupt time−out

sleeping

sleep

  • r. interrupted

wait,join,sleep/ died throw InterruptedException start

existing

new Thread()

dead

interrupt interrupted run.return run.return

  • s. timed−out

interrupt interrupt died interrupt interrupt notify interrupt notify

  • w. int. flag

w.notified

  • w. int. throw
  • j. int. throw
  • j. int. flag
  • s. int. throw
  • s. int. flag

(reacquire lock), reschedule (reacquire lock), reschedule/set interrupted flag (reacquire lock), reschedule/throw InterruptedException

running

c 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ urich.
slide-24
SLIDE 24

Performance – Overhead

23

Barrier Sync LUFact Crypt SOR SMM 10 20 30 40

Sun 1.4 Sun 1.3 Jikes Kaffe Sable

c 2004 V. Schuppan – Computer Systems Institute, ETH Z¨ urich.