© 2007 IBM Corporation IBM Software Group September 26, 2007 Tactics for Minimal Interference from...

11
© 2007 IBM Corporation September 26, 2007 IBM Software Group Tactics for Minimal Interference from Class Loading in Real-Time Java™ The 5th International Workshop on Java Technologies for Real-time and Embedded Systems - JTRES 2007 Institute of Computer Engineering Vienna University of Technology Vienna, Austria Sean Foley, IBM Software Group, Ottawa, Canada [email protected] 613-726-5516
  • date post

    21-Dec-2015
  • Category

    Documents

  • view

    215
  • download

    1

Transcript of © 2007 IBM Corporation IBM Software Group September 26, 2007 Tactics for Minimal Interference from...

© 2007 IBM CorporationSeptember 26, 2007

IBM Software Group

Tactics for Minimal Interference from Class Loading in Real-Time Java™

The 5th International Workshop on Java Technologies for Real-time and Embedded

Systems - JTRES 2007Institute of Computer EngineeringVienna University of Technology

Vienna, Austria

Sean Foley, IBM Software Group, Ottawa, [email protected] 613-726-5516

2

IBM Software Group

Tactics for Minimal Interference from Class Loading in Real-Time Java | JTRES 2007 © 2007 IBM Corporation

Agenda

Motivations for altering class loading behaviour in Real-Time Java

Tactics, experiences, results:– Reducing the size and number of classes to load

– Elimination of premature loading

– Redistribution of loading

– Elimination of repeated loading

– Alternative class formats

Requirements for Implementation of Techniques

3

IBM Software Group

Tactics for Minimal Interference from Class Loading in Real-Time Java | JTRES 2007 © 2007 IBM Corporation

Loading Takes Time

4

IBM Software Group

Tactics for Minimal Interference from Class Loading in Real-Time Java | JTRES 2007 © 2007 IBM Corporation

Motivations and Rationale

Class Loading Impacts Real-Time Requirements

Simplest approach: load everything at startup– Can be optimized

– Not necessarily easy (code paths, development)

– Can be excessive (memory/time), particularly for large apps.

– Not all classes needed for each invocation

Startup time possibly subject to timing constraints

Alternative approaches beneficial for optimal usage of resources

5

IBM Software Group

Tactics for Minimal Interference from Class Loading in Real-Time Java | JTRES 2007 © 2007 IBM Corporation

Instantiated Type Analysis (ITA) determines what methods and classes can be removed

ITA instantiates objects for more accurate analysis to determine reachable items

Basic control flow analysis follows all references with the code

6

IBM Software Group

Tactics for Minimal Interference from Class Loading in Real-Time Java | JTRES 2007 © 2007 IBM Corporation

Advanced Control Flow Analysis

ITA control flow analysis involves exception object throwing and virtual method invocations

7

IBM Software Group

Tactics for Minimal Interference from Class Loading in Real-Time Java | JTRES 2007 © 2007 IBM Corporation

Elimination of loading Induced by Verification

Runtime bytecode verifier loads classes to verify inheritance. Can be avoided by inserting checkcast bytecodes.

Operation Verifier requirement

Non-static field access or method invocation Receiver must be subtype of declaring class of field/method

Field store Stored object must be subtype of field type

Method invocation Arguments must be subtypes of parameters

Return instruction Returned object must be subtype of return type

Throw instruction or exception handler Thrown or caught object must be Throwable

Example:static BaseClass aMethod(SubClass subClass) {

if(subClass == null) throw new NullPointerException();

return subClass;}

Bytecodes: aload_0 aconst_null ifnull new invokespecial checkcastathrow aload_0 checkcastareturn

(Throwable)(BaseClass)

8

IBM Software Group

Tactics for Minimal Interference from Class Loading in Real-Time Java | JTRES 2007 © 2007 IBM Corporation

Cold Method Refactoring: Distributed Loading

Refactoring steps:1. Identify a method to be migrated2. Create a counterpart static method in a

shell class3. Migrate the body of the original method4. Replace the method body with an

invocation of the counterpart

Result: Bytecode verification of the original

method is delayed Loading time of original class is split

The most expensive stage of loading is bytecode verification.

9

IBM Software Group

Tactics for Minimal Interference from Class Loading in Real-Time Java | JTRES 2007 © 2007 IBM Corporation

Persistent Class Sharing Class representations shared amongst VMs: concurrently, sequentially

Cache can exist in shared memory or on file system

Share: classes, strings, compiled code

Not everything shareable: constraints from verifier, advanced optimizations

Multiple shared caches more flexible

Average Time per Class Load

0100200300400500600

No Sharing Sharingwith Cold

Cache

Sharingwith Warm

Cache

Tim

e (m

icro

seco

nd

s) Abs. Max. Time for a Single Class Load

0

10000

20000

30000

No Sharing Sharing withWarm Cache

Tim

e (m

icro

seco

nd

s)

Maximum Load Time

0204060

1

2923

5845

8767

1168

9

1461

1

1753

3

2045

5

2337

7

Time (microseconds)

Sharing Warm Cache No Sharing

IBM LS20 Blade Server / real-time linux / IBM Java5 VM

10

IBM Software Group

Tactics for Minimal Interference from Class Loading in Real-Time Java | JTRES 2007 © 2007 IBM Corporation

Alternative File Formats Load precompiled native code (AOT or ahead-of-time)

With IBM’s WebSphere Real-Time, the steps are:

Other class file formats have been designed

The class file format specification itself allows the delivery of additional data

Jar files

Compile

AOTBoundjar files

Real-timeexecution

Otherjar files

Compile

JavaSource

files

Run

11

IBM Software Group

Tactics for Minimal Interference from Class Loading in Real-Time Java | JTRES 2007 © 2007 IBM Corporation

Summary Class Loading can Interference with Real-Time Constraints

Tactics to alter loading:– Reducing the size and number of classes to load

– Elimination of premature loading

– Temporal redistribution of loading

– Elimination of repeated loading

– Alternative methods of loading

Implementation require analysis, tuning, building, some insight into the app

Tools and resources are available for implementation