270 likes | 432 Views
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.
E N D
Running a Java VM insidean 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. • 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
Implementation ofcurrent network I/O Code • Independent implementations • With similar functionality • Without compatibility • Hardcoded inside the operating systems
Prototyping and Deployment Write-once Run-anywhere...? Deployment Porting Prototyping • Prohibitive development cost • Wasted programming efforts • Limited # of kernel programmers
Yes, Java! Architecture neutral Simplified memory management Easy extension of kernel functionality Code-reuse Write Once Run Anywhere A reasonable approach for kernel extensibility of network I/O
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
MotivationDesign & ImplementationEvaluationDiscussionConcluding Remark
ioctl() dequeue() conf log JVM write() stdout stdin VIFlet enqueue() VIF Packets Design Overview P1 P2 P3 S1 S2 VIF11 VIF12 VIF23 VIF1 Network interface
dequeue() JVM enqueue() 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; } }
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
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
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
Implementation Steps 1) Class Coding 2) VM Implementation 3) Embedding userland run ROMize VIFlet lib lib kernel Test Traffic Source eclipse Embed run BPF device file NVM/NYA run console out NPF diverting socket BPF Dump file viflettester Traffic Generator vifletd Java2 SE VIF
MotivationDesign & ImplementationEvaluationDiscussionConcluding Remark
Eratosthenes Sieve benchmark 91% 11x boosting
Object sort benchmark 6x boosting
93% Priority Queuing throughput
+ VIF FTP code / blocking for disk I/O / buffer copy Kernel VM 8% Function Profiling (FTP send) VM code occupies just a limited portionin the entire processing
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!
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...
MotivationDesign & ImplementationEvaluationDiscussionConcluding Remark
Our work! Even the most straightforward approachexhibited practical performance An ISA more suitable for dynamic compilation would perform much better! Kernel Extensibility favors Optimizations! Virtualization spoils performance?
With an ISA more suitable for dynamic optimization(than Java Bytecode) • 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
Kernel Extensibility favors Optimizations! Socket Socket Socket Socket Socket TCP/UDP TCP/UDP IP IP TCP/UDP / IP Cache EE Traffic Control Ethernet Filter Ethernet Ethernet DD DD DD DD DD Hardcode Customization Layer Integration Speculative Execution Instrumentation We can extend the VIFlet modelfor further flexibility!
MotivationDesign & ImplementationEvaluationDiscussionConcluding Remark
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, such 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
? || /* */ The source will be released at SourceForge, shortly. Check for the latest news at http://www.netnice.org!