Running a Java VM inside an Operating System kernel - a networking case study -

27
Running a Java VM Running a Java VM inside inside an Operating System kernel an Operating System kernel - a networking case study - - a networking case study - Department of Computer Science University of Pittsburgh Takashi Okumura Takashi Okumura , Bruce Childers, Daniel Mosse’ , Bruce Childers, Daniel Mosse’

description

Running a Java VM inside an Operating System kernel - a networking case study -. Department of Computer Science University of Pittsburgh. Takashi Okumura , Bruce Childers, Daniel Mosse’. Introduction. Takashi Okumura, M.D., Ph.D. - PowerPoint PPT Presentation

Transcript of Running a Java VM inside an Operating System kernel - a networking case study -

Page 1: Running a Java VM  inside an Operating System kernel - a networking case study -

Running a Java VMRunning a Java VM inside inside

an Operating System kernelan Operating System kernel- a networking case study -- a networking case study -

Department of Computer ScienceUniversity of Pittsburgh

Takashi OkumuraTakashi Okumura, Bruce Childers, Daniel Mosse’, Bruce Childers, Daniel Mosse’

Page 2: Running a Java VM  inside an Operating System kernel - a networking case study -

2/27Running a Java VM inside an Operating System kernelVEE 2008

• Takashi Okumura, M.D., Ph.D.– Doctor of Medicine (Mar 2007)

Asahikawa Medical College, Japan.

– Ph.D. in Computer Science (April 2007)Department of Computer Science,University of Pittsburgh

• Current appointment– resident @ Furano hospital, Hokkaido– rotating the department of surgery

• Research Interest– Network I/O virtualization– Semantics-aware medical network

Introduction

Page 3: Running a Java VM  inside an Operating System kernel - a networking case study -

3/27Running a Java VM inside an Operating System kernelVEE 2008

Implementation ofcurrent network I/O Code

• Independent implementations• With similar functionality• Without compatibility• Hardcoded inside the operating systems

Page 4: Running a Java VM  inside an Operating System kernel - a networking case study -

4/27Running a Java VM inside an Operating System kernelVEE 2008

• Prohibitive development cost• Wasted programming efforts• Limited # of kernel programmers

Porting

Prototyping

Prototyping and Deployment

Write-once Run-anywhere...?

Deployment

Page 5: Running a Java VM  inside an Operating System kernel - a networking case study -

5/27Running a Java VM inside an Operating System kernelVEE 2008

Yes, Java!

• Architecture neutral• Simplified memory management• Easy extension of kernel functionality• Code-reuse

A reasonable approach forkernel extensibility of network I/O

Write Once Run Anywhere

Page 6: Running a Java VM  inside an Operating System kernel - a networking case study -

6/27Running a Java VM inside an Operating System kernelVEE 2008

Need for an in-kernel JVM

• A Java Virtual Machine that is…– Compact enough to be embedded in kernel

– Efficient enough to run in kernel

– Open-source, usable for research

• No such VM present...– We built such an in-kernel JVM that meets the criteria

and is reusable for other purposes

Page 7: Running a Java VM  inside an Operating System kernel - a networking case study -

Motivation

Design & Implementation

Evaluation

Discussion

Concluding Remark

Page 8: Running a Java VM  inside an Operating System kernel - a networking case study -

8/27Running a Java VM inside an Operating System kernelVEE 2008

Design Overview

P1 P2 P3

VIF23

VIF1

VIF11 VIF12

S1 S2

Network interface

JVM

Packets

VIF

VIFlet

ioctl()

write()

conf log

stdin

stdout

enqueue()

dequeue()

Page 9: Running a Java VM  inside an Operating System kernel - a networking case study -

9/27Running a Java VM inside an Operating System kernelVEE 2008

import org.netnice.*;

public class PriQVIFlet extends VIFlet {private static final int NCLASS = 4;private Queue[] queue;private PacketClassifier pc = new SimplePacketClassifier();private int length = 0;

PriQVIFlet() {queue = new Queue[NCLASS];for (int i = 0; i < NCLASS; i++)

queue[i] = new Queue();}

public void enqueue(Packet p) {if (p == null)

return;

p.mark = pc.classify(p);queue[p.mark % NCLASS].enqueue(p);this.length++;

}

public Packet dequeue() {for (int i = 0; i < NCLASS; i++)

if (queue[i].isEmpty() != true) {this.length--;return queue[i].dequeue();

}

return null;}

}

JVM

enqueue()

dequeue()

Page 10: Running a Java VM  inside an Operating System kernel - a networking case study -

10/27Running a Java VM inside an Operating System kernelVEE 2008

NVM/NYAA Lightweight In-kernel JVM/JIT

• NVM– Interpreter (based on Waba VM)

– Integrated Class library– 64K (incl. classlib)

• NYA– JIT for NVM (reusing code mgmt framework of TYA)

– Simple table-driven translator– 64K

Many Optimizations and Protection features added

Page 11: Running a Java VM  inside an Operating System kernel - a networking case study -

11/27Running a Java VM inside an Operating System kernelVEE 2008

Optimizations

• Specification– Supports only 32 bit variable– Omitted several Java constructs, such as Exception,

Thread, and Monitor– Omitted the code verification

• Optimization algorithms– Register cache of locals, Instruction folding, Object cache,

Array object cache, Method cache, fast invocation routine, etc…

• Run Time– Native functions for costly processing– Enforce only one reference to a packet object – Discourage users to create objects in event handlers,

not to start GC

Page 12: Running a Java VM  inside an Operating System kernel - a networking case study -

12/27Running a Java VM inside an Operating System kernelVEE 2008

Protection Features

• Stack Depth Counter– to avoid recursive calls

• Software Timer– to avoid infinite loops

• Isolation of Execution– VIF framework partitions each execution

• No code verification (ostrich approach)

– Terminates when illegal instruction is executed– Access is strictly limited within the Java heap

Page 13: Running a Java VM  inside an Operating System kernel - a networking case study -

13/27Running a Java VM inside an Operating System kernelVEE 2008

Implementation Steps

VIFlet

eclipse

viflettester

run console out

lib

NVM/NYA

lib

vifletdJava2 SE

run

2) VM Implementation

Test Traffic Source

Embed run

1) Class Coding 3) Embedding

Traffic Generator

BPF Dump file

BPF device file

NPF diverting socket

ROMize

VIF

kernel

userland

Page 14: Running a Java VM  inside an Operating System kernel - a networking case study -

Motivation

Design & Implementation

Evaluation

Discussion

Concluding Remark

Page 15: Running a Java VM  inside an Operating System kernel - a networking case study -

15/27Running a Java VM inside an Operating System kernelVEE 2008

Eratosthenes Sieve benchmark

11x boosting91%

Page 16: Running a Java VM  inside an Operating System kernel - a networking case study -

16/27Running a Java VM inside an Operating System kernelVEE 2008

Object sort benchmark

6x boosting

Page 17: Running a Java VM  inside an Operating System kernel - a networking case study -

17/27Running a Java VM inside an Operating System kernelVEE 2008

Priority Queuing throughput

93%

Page 18: Running a Java VM  inside an Operating System kernel - a networking case study -

18/27Running a Java VM inside an Operating System kernelVEE 2008

Function Profiling (FTP send)

FTP code / blocking for disk I/O / buffer copy Kernel VM

8%

+ VIF

VM code occupies just a limited portionin the entire processing

Page 19: Running a Java VM  inside an Operating System kernel - a networking case study -

19/27Running a Java VM inside an Operating System kernelVEE 2008

Performance breakdown

• Avoid method invocation by smart in-lining• Reduce the native call cost• Avoid (packet) object creation in the kernel

– pre-allocate necessary objects at system boot time!

Page 20: Running a Java VM  inside an Operating System kernel - a networking case study -

20/27Running a Java VM inside an Operating System kernelVEE 2008

Compilation Cost

• Invest on the class-loading cost, for performance boosting– by a sophisticated class loader…

• Invest on the translation cost (register allocation)– by a better ISA more suitable for dynamic code generation...

Page 21: Running a Java VM  inside an Operating System kernel - a networking case study -

Motivation

Design & Implementation

Evaluation

Discussion

Concluding Remark

Page 22: Running a Java VM  inside an Operating System kernel - a networking case study -

22/27Running a Java VM inside an Operating System kernelVEE 2008

Virtualization spoils performance?

An ISA more suitable for dynamic compilation would perform much better!

Kernel Extensibility favors Optimizations!

Even the most straightforward approachexhibited practical performance

Our work!

Page 23: Running a Java VM  inside an Operating System kernel - a networking case study -

23/27Running a Java VM inside an Operating System kernelVEE 2008

• AOT approach (by M. Welsh) is advantageous, because it can afford costly optimizations– However, AOT performs only static optimizations– JIT is a primitive way of dynamic optimization

It would perform much better,

by incorporating execution profile of running programs...

AOT vs JIT

With an ISA more suitable for dynamic optimization

(than Java Bytecode)

Page 24: Running a Java VM  inside an Operating System kernel - a networking case study -

24/27Running a Java VM inside an Operating System kernelVEE 2008

DD

Ethernet

Filter

TCP/UDP

Socket

Traffic Control

IP

Hardcode

Socket

DD

Cache

SpeculativeExecution

Socket

DD

Ethernet

TCP/UDP / IP

LayerIntegration

Socket

DD

Instrumentation

EE

DD

Ethernet

TCP/UDP

Socket

IP

Customization

Kernel Extensibility favors Optimizations!

We can extend the VIFlet modelfor further flexibility!

Page 25: Running a Java VM  inside an Operating System kernel - a networking case study -

Motivation

Design & Implementation

Evaluation

Discussion

Concluding Remark

Page 26: Running a Java VM  inside an Operating System kernel - a networking case study -

26/27Running a Java VM inside an Operating System kernelVEE 2008

• Produced an Empirical proof– Virtualized code does not jeopardize OS performance,

dismissing the common belief…

• Found practical optimizations– to efficiently execute packet processing Java programs in kernel, su

ch as simplification of the language specification, restriction of the packet duplication, heuristics in garbage collection, etc…

• Produced an efficient in-kernel JVM– reusable for many other purposes, with a variety of lessons leaned

and execution profiles to guide future research efforts in the domain

Contributions

Page 27: Running a Java VM  inside an Operating System kernel - a networking case study -

? || /* */

The source will be released at SourceForge, shortly. Check for the latest news at http://www.netnice.org!