no heap remote objects for distributed real-time java

20
No Heap Remote Objects for Distributed Real-Time Java Pablo Basanta-Val, Marisol García-Valls, and Iria Estévez-Ayres mailto:[email protected] †Jornadas de Tiempo Real 2011- Madrid( ) Publicado en ACM Transactions On Embedded Systems

Upload: universidad-carlos-iii-de-madrid

Post on 30-Jun-2015

211 views

Category:

Education


2 download

TRANSCRIPT

Page 1: No Heap Remote Objects for Distributed real-time Java

No Heap Remote Objects for Distributed Real-Time Java

Pablo Basanta-Val, Marisol García-Valls, and Iria Estévez-Ayres

mailto:[email protected]

†Jornadas de Tiempo Real 2011- Madrid( ) Publicado en ACM Transactions On Embedded Systems

Page 2: No Heap Remote Objects for Distributed real-time Java

Outline• Context and Motivation• No-Heap Remote Objects

– Basic Model• Programming model• Example• Performance

– Extended Model• Programming patterns• Extended model• Performance

• Conclusion and ongoing work

2

Page 3: No Heap Remote Objects for Distributed real-time Java

Memory management for real-time Java• Techniques used for memory management in real-time Java

(RTSJ)– Auto-managed memory (object pools)– Garbage collection (and its RT* variants)– Regions (ScopedMemory)

• Memory management issues in distributed real-time Java (DRTSJ)– Real-time garbage collection– Distributed Garbage Collection– Regions

• Current garbage collectors may be not enough for distributed real-time applications– E.g. a heap with 1Gb may introduce a 30 seconds delay

JRT-11 3

Page 4: No Heap Remote Objects for Distributed real-time Java

State of the art

JRT-11 4

Denomination Technologies Goals

RTZenRT- CORBA+

RTSJ

Implementation of RT-CORBA with RTSJ

DRTSJ RMI+RTSJ A specification for distributed real-time Java

RT-RMI-York RMI+RTSJ A framework for distributed real-time Java.

RT-RMI-UPM RMI+RTSJ Profiles for distributed real-time Java

DRTJava-on-CSP CSP+JavaProduce an alternative based on CSP

formalisms

RTJ-COM RTSJ A component framework for embedded Java

Scratchpad RTSJ A no-heap component model for real-time Java

APICOM RTSJ +CANA distributed real-time object-oriented

platform• There is not a simple technique to remove the GC’s from the server side !!!• RTZen hybrid approach, • DRTSJ , RTRMI-York, RTRMI-UPM take non-heap as a requirement

Page 5: No Heap Remote Objects for Distributed real-time Java

5

RTSJ region-based memory model

• Three types of memory areas– Heap– Immortal Memory (I)– Scoped Memory (Sx)

• A selector mechanism– One scope stack per thread– Enter, executeInArea

• Destruction mechanism– Stack discipline (counter)

• Safety mechanism– Assignment rule – Single parent rule

Scope Stack

I

Sb

Sa O1

O2

:O1=new Object

1

1

Forbidden assignment

Default allocation context

Page 6: No Heap Remote Objects for Distributed real-time Java

6

NhRo: memory model

• Fragmented memory model– Creation Context

• Represents the state of the remote object

– Invocation Context• Objects created during remote invocation

• Safe nesting of contexts– NhRo-rule: references from creation to invocation are

forbidden– References from invocation to creation are allowed

Calculator()lastInteger

add()lastResult()doNothing()

Calculator()lastInteger

add()lastResult()doNothing()

Page 7: No Heap Remote Objects for Distributed real-time Java

NhRo:Example

JRT-11 7

01: public class CalculatorImpl extends 02: es.uc3m.it.drequiem.rtrmi.NoHeapRealtimeRemoteObject03: implements Calculator{

04: private DataInt lastInteger=new DataInt(0);//Last result05: private ExtendedPortal ep= new ExtendedPortal(null);06: public CalculatorImpl()07: throws java.rmi.RemoteException{08: super(0, false, null, null, null, 08: new LTMemoryAreaPool(5,5,1000,1000) //IC factory09: ,null);}

10: public DataInt add(DataInt a, DataInt b)11: throws java.rmi.RemoteException{12: int aux1=a.intValue();13: int aux2=b.intValue();14: DataInt tmp=new DataInt(aux1+aux2);15: lastInteger=tmp; //violates NhRo-rule !!16: return lastInteger;17: }18: public DataInt lastResult()trows java.rmi.RemoteException{19: return lastInteger; }20: public void doNothing()throws java.rmi.RemoteException{21: }22: public Calculator getNewCalculator() throws ... {23: Calculator newC=(Calculator)new CalculatorImpl();24: return newC;25: }26: }

CalculatorImpl.java

public interface Calculator extends java.rmi.Remote{ public DataInt add(DataInt i, DataInt o) throws java.rmi.RemoteException; public DataInt lastResult() throws java.rmi.RemoteException; public void doNothing() throws java.rmi.RemoteException; public Calculator getNewCalculator()

throws java.rmi.RemoteExceptioo;}

Calculator.java

public class DataInt implements Serializable{ private int internalvalue=0; public DataInt(int i){internalvalue=i;}; public int intValue(){

return internalvalue;} public void setIntValue(int i){ internalvalue=i; }}

DataInt.java

Creation Context

Invocation Context

Invocation Context

X

Page 8: No Heap Remote Objects for Distributed real-time Java

8

NhRo: Impact on the middleware

Remote Object Table

ProgrammerLayer

Middleware Layer

RTSJVirtual Machine

JRMP/IIOP

CalculatorImpl

add()lastResult()

doNothing()

lastInteger

CalculatorImpl_Stub

add()lastResult()

doNothing()

Thread Pool

Memory Area Pool

0Invo

cati

onm

ax

Scop

ed o

r Im

mor

tal

Imm

orta

l mem

ory

Client Server

0Invo

cati

on1

TransportTransport

ObjId Ref CC CalcID

Page 9: No Heap Remote Objects for Distributed real-time Java

9

NhRo in action

Memory Area pool

0 0 0

Thread pool

Transport

Calculator()lastInteger

add()lastResult()doNothing()

OBJId Table

CalcID Ref

CalcID.add(DataInt(3),DataInt(4))

enter

DataInt(7)

1

a b

tmp ser

objID

meth

Middleware created object

Program created object

Creation Context(Immortal Memory)

Invoc. Context(LTMemory)

1

Page 10: No Heap Remote Objects for Distributed real-time Java

NhRo vs. traditional GC’d remote objects

JRT-11 10

0

1

2

3

4

5

6

7

8

1 21 41 61 81 101 121 141sample

Co

nsu

mm

ed

tim

e (

ms)

Garbage collector RTSJ-RI Memory area pool

0

2

4

6

8

10

12

14

16

752

1286

1910

2534

3158

Alive memory (kB)

Co

nsu

mm

ed t

ime

(ms)

Garbage collector RTSJ-RI Memory area pool

Page 11: No Heap Remote Objects for Distributed real-time Java

Enhancements to the basic NhRo model• Patterns for programming with NhRos• NhRo stored in scoped memory

– Scope stack characterization– Changes in the middleware– Policies for the memory are pool

• Performance issues– Dependency on data transmitted

JRT-11 11

Page 12: No Heap Remote Objects for Distributed real-time Java

12

NhRo: constraints (I)

• NhRo-rule limitations– Objects is creation context are destroyed after

remote invocation by default

• Two patterns to avoid the problem– Copy pattern– Extended portals

Calculator()lastInteger

add()lastResult()doNothing()

Page 13: No Heap Remote Objects for Distributed real-time Java

13

NhRo: Scope Stack at the server

• Creation context: state of the remote object• Invocation context: parameters of remote invocation

Scope Stack (during remote object creation)

I

Sb

Sa RO1

:RO1=new RemoteObject

1

1

Cre

atio

n co

ntex

t

HandlerThread

Scope Stack (during remote invocation)

I

Sb

Sa RO1

1

1

Sinv1

1

Cre

atio

n co

ntex

tIn

voca

tion

cont

ext

a b

Page 14: No Heap Remote Objects for Distributed real-time Java

Decoupling middleware implemenation from NhRos

JRT-11 14

ObjID Ep

CalcID

Remote Object Table

CalculatorImpl

addlastResultdoNothing

lastInteger

getNewCalc

Thread Pool Memory Area Pool

0

Invo

cati

onm

ax

0Invo

cati

on1b

aI

Server

scopeb

scopea

immortal

scope stack

2

2

Performing a remote invocationat the server's side

invocationx

handler thread

2

1

2

1

1

remote object instance

invocation parameter

b

3

a

Scoped or Immortal

Scoped or Immortal

Page 15: No Heap Remote Objects for Distributed real-time Java

15

Memory Area Pool

• It stores LTMemory instances only

• It requires two configuration parameters– Number of instances in the pool– Memory associated to each invocation context

• Auto-collection– Invocation context returns automatically to its pool when

they are not used• Internal counter 10• Avoids memory area leakage

Memory Area Pool

0 0 0

Invocationnumber

Invo

cati

onsi

ze

Page 16: No Heap Remote Objects for Distributed real-time Java

Remove invocation parameters and LTMemory size

JRT-11 16

0

5000

10000

15000

20000

25000

30000

void

bool

ean

byte

char

shor

t

int

long

float

doub

le

null

Byt

e

Sho

rt

Inte

ger

Long

Flo

at

Dou

ble

Cha

ract

er

Boo

lean

RtU

nRem

Ob

Str

ing(

)

Str

ing(

10)

Str

ing(

25)

Str

ing(

50)

Str

ing(

100)

Obj

ect[0

]

Obj

ect[1

0D]

Obj

ect[2

5D]

Obj

ect[5

0D]

Obj

ect[1

00D

]

Vec

tor(

0)

Vec

tor(

10D

)

Vec

tor(

25D

)

Vec

tor(

50D

)

Vec

tor(

100D

)

X

byt

es

void doNothing(X)

X doNothing()

X echo(X)

Page 17: No Heap Remote Objects for Distributed real-time Java

NhRos vs. (RT*) Garbage Collectors [new]

JRT-11 17

Page 18: No Heap Remote Objects for Distributed real-time Java

Conclusions

• This work has introduced a model able to remove the garbage collection from the end-to-end path– NhRo model

• Empirical results showed:– Its implementation in basic environments is simple– The performance patterns offered are powerful

JRT-11 18

Page 19: No Heap Remote Objects for Distributed real-time Java

Ongoing Work-

• To produce an analytic model for the NhRo– Use of heap, and different threads– Identification of useful combinations

• Analyze the parentage-rules proposed by Higuera-Toledano and integrate them with NhRos– A more restricted model

JRT-11 19

Page 20: No Heap Remote Objects for Distributed real-time Java

JRT-11 20