+ All Categories
Home > Documents > JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation...

JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation...

Date post: 17-Aug-2020
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
33
JiST : Java in Simulation Time Transparent Parallel and Optimistic Execution of Discrete Event Simulations (PDES) of Mobile Ad hoc Networks (MANETs) Rimon Barr [email protected] Wireless Network Lab Cornell University 3 March 2003 http://www.cs.cornell.edu/barr/repository/jist/
Transcript
Page 1: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

JiST:Java in Simulation Time

Transparent Parallel and Optimistic Execution of

Discrete Event Simulations (PDES)of Mobile Ad hoc Networks (MANETs)

Rimon [email protected]

Wireless Network LabCornell University

3 March 2003

http://www.cs.cornell.edu/barr/repository/jist/

Page 2: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 2

introduction

• discrete event simulations are useful• physics, chemistry, genomics, proteomics• geology, meteorology, astronomy• processors, networks

• basic structure• simulation time• state (partitioned)• events, event queue

• ad hoc network simulations• lack scalability, or• compromise detail

Page 3: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 3

simulating ad hoc wireless networks

• scale• large number of nodes• expensive to own, maintain, charge...• distribution of control• aggregation of experimental data• node mobility• isolating experiment from interference

• complexity• simple protocols vs.

aggregate network behavior• repetition

Page 4: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 4

existing MANET simulators

• ns2• PDNS• OPNet• GlomoSim• custom-made

Page 5: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 5

design space

• interpreted executionvs. compiled

• general purpose languagevs. domain specific

• shared nothing architecturevs. shared everything

Page 6: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 6

design space

• interpreted executionvs. compiled

pros:• runtime inspection, interrupts, debugging• simulation composition and configuration• reflection facilitates debugging

cons:• rely on JIT for performance

Page 7: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 7

design space

• general purpose languagevs. domain specific

pros:• credibility, code re-use• general compiler advances• familiarity, other software engineering arguments

cons:• specific compiler optimizations

Page 8: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 8

design space

• shared nothing architecturevs. shared everything

pros:• inexpensive (COTS)• portable, simple

cons:• synchronization• serialization

Page 9: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 9

existing MANET simulators

• ns2 is the gold standard• Tcl-based, with C++ bindings• used extensively within research community• initially developed for detailed TCP simulations• Monarch – modified to support ad hoc networks• processor and memory intensive, sequential• O(n3)• max. ~ 250 nodes

• PDNS – parallel distributed ns2• perform event loop over Georgia Tech. RTI-KIT• requires fast inter-connect• helps with memory limits

• OPNet

Page 10: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 10

existing MANET simulators

• Glomosim• written in Parsec, a custom C-like language• entities map to processes

messages map to IPCs• “node aggregation”

• imposes conservative parallelism

• max. ~10,000 nodes• but on NUMA: Sun SPARCserver 1000, est. $300,000

• custom-made simulators• fast, specialized computation• lack sophisticated execution, parallelism• credibility

Page 11: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 11

java in simulation time

• Java-based simulation framework

• runs discrete event simulations• efficiently

• in parallel• optimistically

• transparently• simulations written in plain Java• compiled class files are modified at load time

• proof of concept• SWANS – Scalable Wireless Ad hoc Network Simulation• ideas not specific to Java

Page 12: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 12

simulation time

• program time• progress of program independent of time

• real time• progress of program dependent on time

• simulation time• progress of time dependent on program• simulation event loop embedded in virtual machine• simulation time is advanced by the program

Page 13: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 13

an example

• the “hello world” of discrete event simulations

• result: one event per time step

class MySim implements JistAPI.Entity{private int data = 0;public void myEvent() {

JistAPI.sleep(1);myEvent();System.out.println("myEvent, sim-time="+

JistAPI.getTime()+" data="+(data++));}

}

class MySim implements JistAPI.Entity{private int data = 0;public void myEvent() {

JistAPI.sleep(1);myEvent();System.out.println("myEvent, sim-time="+

JistAPI.getTime()+" data="+(data++));}

}

Page 14: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 14

jist api

• JistAPI class provides application `calls’ to the JiST runtime

• permits standard Java compilation

• runs on standard Java VM

interface Entity - tag object as entity

long getTime() - return simulation timevoid sleep(long t) - advance simulation time

EntityRef THIS - reference to this entityEntityRef ref(Entity e) - reference to entity

interface Entity - tag object as entity

long getTime() - return simulation timevoid sleep(long t) - advance simulation time

EntityRef THIS - reference to this entityEntityRef ref(Entity e) - reference to entity

Page 15: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 15

entities and separators

• program state contained in objects• objects partitioned into entities• entities must not share state

• live objects are referenced by exactly one entity

• therefore, each entity has its own entity time

• think, component interface...

Page 16: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 16

entities and separators

• separators (or entity references)• separate application state, application time• provide location independence

• method calls to entities• non-blocking• invoked at caller entity time• no continuation

• neither return, nor exception

Page 17: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 17

rewriting simulations

• dynamic class loader• no source code access• uses Apache Byte Code Engineering Library (BCEL)• ignores non-application packages

• steps• verification• add entity self reference• intercept entity state (field) access• add method stub fields• intercept entity invocations• modify entity creation• modify entity references• modify typed instructions• translate JiST API calls

Page 18: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 18

rewriting simulations

• verification• entity state private and non-static• no native, abstract, non-static methods in entities• no continuations after entity invocations

• entity methods should return void• exceptions escaping entities cause simulation failure

public class MyEntity implements JistAPI.Entity{public void event1(...) {

... }

}

public class MyEntity implements JistAPI.Entity{public void event1(...) {

... }

}

Page 19: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 19

rewriting simulations

• add entity self reference to entity• add self reference field• initialize self reference in constructor• implement jist.runtime.Entity interface

class MyEntity implements JistAPI.Entity {private EntityRef _jistField__ref;public MyEntity(...) {

super(...);this._jistField__ref = jist.runtime.Controller.registerEntity(this);

...}

}

class MyEntity implements JistAPI.Entity {private EntityRef _jistField__ref;public MyEntity(...) {

super(...);this._jistField__ref = jist.runtime.Controller.registerEntity(this);

...}

}

Page 20: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 20

rewriting simulations

• intercept entity state (field) access• all entity fields made private• get and set accessor methods added for entity fields• get/set-field/static into method invocations

public class MyEntity implements JistAPI.Entity{

//public int i;private int i;public void _jistMethod_Set_i(int i) { this.i = i; }public int _jistMethod_Get_i() { return i; }

}

public class MyEntity implements JistAPI.Entity{

//public int i;private int i;public void _jistMethod_Set_i(int i) { this.i = i; }public int _jistMethod_Get_i() { return i; }

}

Page 21: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 21

rewriting simulations

• add entity method stub fields to entity• statically initialized

class MyEntity implements JistAPI.Entity {public void myEvent(...) { ... }public static Method _jistMethodStub_myEvent$signature$;static{

jist.runtime.Rewriter.MethodStubInit("MyEntity");}

}

class MyEntity implements JistAPI.Entity {public void myEvent(...) { ... }public static Method _jistMethodStub_myEvent$signature$;static{

jist.runtime.Rewriter.MethodStubInit("MyEntity");}

}

Page 22: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 22

rewriting simulations

• intercept entity invocations• convert into method call to JiST runtime• pack arguments into object array (type safety)• pass correct method stub instance and entity instance

...//myentity.event1(1, "foo");jist.runtime.Controller.entityInvocation(MyEntity._jistMethodStub_event1$28ILjava$2elang$2eString$3b$29V,myentity,new Object {

new Integer(1),"foo"

});...

...//myentity.event1(1, "foo");jist.runtime.Controller.entityInvocation(MyEntity._jistMethodStub_event1$28ILjava$2elang$2eString$3b$29V,myentity,new Object {

new Integer(1),"foo"

});...

Page 23: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 23

rewriting simulations

• modify entity creation• creates a new entity• returns entity reference to new entity

...//MyEntity f = new MyEntity(...);EntityRef f = (new MyEntity(...))._jistField__ref

...

...//MyEntity f = new MyEntity(...);EntityRef f = (new MyEntity(...))._jistField__ref

...

Page 24: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 24

rewriting simulations

• modify entity references• field entity types• method parameter entity types• method return entity types

public class MyEntity implements JistAPI.Entity{//public SomeEntity entity;

public EntityRef entity2//public void event(SomeEntity e, int i) {

public void event(EntityRef e, int i) {...

}}

public class MyEntity implements JistAPI.Entity{//public SomeEntity entity;

public EntityRef entity2//public void event(SomeEntity e, int i) {

public void event(EntityRef e, int i) {...

}}

Page 25: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 25

rewriting simulations

• modify typed instructions• type casts

• translate JiST API calls• sleep(), getTime(), THIS, ref()

class MySim implements JistAPI.Entity {//public void myEvent(MySim sim) {public void myEvent(EntityRef sim) {//JistAPI.sleep(1);

JistAPI_Impl.sleep(1);if ( JistAPI_Impl.getTime() < 100 )

//sim.myEvent((MySim)JistAPI.THIS));sim.myEvent((EntityRef)JistAPI_Impl.getTHIS());

System.out.println("myEvent, time="+JistAPI_Impl.getTime());

}}

class MySim implements JistAPI.Entity {//public void myEvent(MySim sim) {public void myEvent(EntityRef sim) {//JistAPI.sleep(1);

JistAPI_Impl.sleep(1);if ( JistAPI_Impl.getTime() < 100 )

//sim.myEvent((MySim)JistAPI.THIS));sim.myEvent((EntityRef)JistAPI_Impl.getTHIS());

System.out.println("myEvent, time="+JistAPI_Impl.getTime());

}}

Page 26: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 26

benefits of rewriting approach

• standard Java compilation• standard Java Virtual Machine• no source code access required• retains type-safety properties• rewriting occurs once, at load time• partitioning of application state into entities• location independence of entities• event loop embedded into virtual machine• transparent parallel and optimistic execution• dynamic and interpreted environment

• yet, efficient…

Page 27: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 27

benefits of rewriting approach

• micro-benchmark of event throughput• includes garbage collection• includes event scheduling• includes message passing• … still preliminary!

# e

ven

ts

JiS

T

Glo

mo

Sim

Ra

tio

10^5 0.22s 0.48s 45%10^6 1.44s 3.18s 45%10^7 13.55s 30.46s 44%10^8 130.6s 292.5s 45%

serial throughput increase of 2.2x

class MySim implements JistAPI.Entity{

private int data = 0;public void myEvent() {

JistAPI.sleep(1);myEvent();System.out.println("myEvent, \

sim-time="+JistAPI.getTime()+" data="+(data++));

}}

class MySim implements JistAPI.Entity{

private int data = 0;public void myEvent() {

JistAPI.sleep(1);myEvent();System.out.println("myEvent, \

sim-time="+JistAPI.getTime()+" data="+(data++));

}}

Page 28: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 28

serial simulation time

• program state in objects• objects partitioned among entities• separators of state, time• serial execution

• inject orthogonal code• inspection, node mobility, debugging

Page 29: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 29

current status

• rewriter working• simulation infrastructure working

• serial execution

• building swans• designing physical layer

• parallelization• optimistic execution

• check-pointing and undo• bounding, load balancing

Page 30: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 30

coming soon: a real application

• SWANS• Scalable Wireless Ad hoc Network Simulator

• implement• physical: propagation, reception• link: 802.11b• routing: DSR or ZRP• application: CBR• mobility model

Page 31: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 31

coming soon: parallel simulation time

• lock-step in simulation time• concurrent events• conservative

• separators• location-independence• entity tracking

• balance load• minimize network overhead

Page 32: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

Rimon Barr, Wireless Network Lab, 3 March 2003 JiST: Transparent parallel and optimistic execution of PDES of MANETs: 32

coming soon: optimistic simulation time

• checkpoint entities• cascade undo

• cancellation• propagation

• rollback interface• automatic rollback method generation

• balance forward progress of time

Page 33: JiSTjist.ece.cornell.edu/docs/030303-wnl.pdf · java in simulation time • Java-based simulation framework • runs discrete event simulations • efficiently • in parallel •

JIST:Java In Simulation Time

Transparent Parallel and Optimistic Execution of

PDES of MANETs

Thank you.

http://www.cs.cornell.edu/barr/repository/jist/


Recommended