Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Running a Java VM inside an Operating System kernel - a networking case study - Takashi Okumura, Bruce Childers, Daniel Mosse’ Department of Computer Science University of Pittsburgh 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 – – VEE 2008 Network I/O virtualization Semantics-aware medical network Running a Java VM inside an Operating System kernel 2/27 Implementation of current network I/O Code • • • • VEE 2008 Independent implementations With similar functionality Without compatibility Hardcoded inside the operating systems Running a Java VM inside an Operating System kernel 3/27 Prototyping and Deployment Write-once Run-anywhere...? Deployment Porting Prototyping VEE 2008 • Prohibitive development cost • Wasted programming efforts • Limited # of kernel programmers Running a Java VM inside an Operating System kernel 4/27 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 VEE 2008 Running a Java VM inside an Operating System kernel 5/27 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 VEE 2008 Running a Java VM inside an Operating System kernel 6/27 Motivation Design & Implementation Evaluation Discussion Concluding Remark Design Overview P1 P2 P3 ioctl() conf S1 VIF11 dequeue() log S2 VIF12 VIF23 stdout JVM stdin VIFlet VIF1 write() enqueue() VIF Network interface VEE 2008 Packets Running a Java VM inside an Operating System kernel 8/27 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(); } dequeue() public void enqueue(Packet p) { if (p == null) return; JVM p.mark = pc.classify(p); queue[p.mark % NCLASS].enqueue(p); this.length++; enqueue() } public Packet dequeue() { for (int i = 0; i < NCLASS; i++) if (queue[i].isEmpty() != true) { this.length--; return queue[i].dequeue(); } return null; } } VEE 2008 Running a Java VM inside an Operating System kernel 9/27 NVM/NYA A 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 – Simple table-driven translator – 64K TYA) Many Optimizations and Protection features added VEE 2008 Running a Java VM inside an Operating System kernel 10/27 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 VEE 2008 Running a Java VM inside an Operating System kernel 11/27 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 VEE 2008 Running a Java VM inside an Operating System kernel 12/27 Implementation Steps 1) Class Coding 2) VM Implementation 3) Embedding userland run ROMize VIFlet lib eclipse Test Traffic Source BPF device file run console out NPF diverting socket lib NVM/NYA Embed kernel run BPF Dump file viflettester Java2 SE VEE 2008 Traffic Generator vifletd Running a Java VM inside an Operating System kernel VIF 13/27 Motivation Design & Implementation Evaluation Discussion Concluding Remark Eratosthenes Sieve benchmark 11x boosting VEE 2008 91% Running a Java VM inside an Operating System kernel 15/27 Object sort benchmark 6x boosting VEE 2008 Running a Java VM inside an Operating System kernel 16/27 Priority Queuing throughput 93% VEE 2008 Running a Java VM inside an Operating System kernel 17/27 Function Profiling (FTP send) + VIF FTP code / blocking for disk I/O / buffer copy Kernel VM 8% VM code occupies just a limited portion in the entire processing VEE 2008 Running a Java VM inside an Operating System kernel 18/27 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! VEE 2008 Running a Java VM inside an Operating System kernel 19/27 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... VEE 2008 Running a Java VM inside an Operating System kernel 20/27 Motivation Design & Implementation Evaluation Discussion Concluding Remark Virtualization spoils performance? Even the most straightforward approach exhibited practical performance An ISA more suitable for dynamic compilation would perform much better! Kernel Extensibility favors Optimizations! VEE 2008 Running a Java VM inside an Operating System kernel 22/27 With an ISA more suitable for dynamic optimization (than Java Bytecode) It would perform much better, by incorporating execution profile of running programs... AOT vs JIT • 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 VEE 2008 Running a Java VM inside an Operating System kernel 23/27 Kernel Extensibility favors Optimizations! Socket Socket TCP/UDP TCP/UDP IP IP Traffic Control Socket Socket Socket TCP/UDP / IP Cache EE Ethernet Filter Ethernet Ethernet DD DD DD DD DD Hardcode Customization Layer Integration Speculative Execution Instrumentation We can extend the VIFlet model for further flexibility! VEE 2008 Running a Java VM inside an Operating System kernel 24/27 Motivation Design & Implementation Evaluation Discussion Concluding Remark Contributions • 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 VEE 2008 Running a Java VM inside an Operating System kernel 26/27 ? || /* */ The source will be released at SourceForge, shortly. Check for the latest news at http://www.netnice.org!