Multitasking without Compromise: a Virtual Machine Evolution Grzegorz Czajkowski Laurent Daynes Sun Microsystems Laboratories Presented by: Subodh J. Lele 12/02/2004 CS 5204 - Fall 2004
Introduction - Java VM Used by applications, applets Appears as an OS Ad hoc layer JVM Base OS 12/02/2004 CS 5204 - Fall 2004
Problems Interference between two apps Examples All are undesired! Monopoly over heap space Leaky object references Sharing event and finalization queues Internalized strings All are undesired! 12/02/2004 CS 5204 - Fall 2004
Internalized Strings Avoids duplicates String a = “abc”; String b = a.intern(); Need to use synchronized (a) { … } 12/02/2004 CS 5204 - Fall 2004
Solutions Separate VMs Multitasking VM (MVM) Each VM as a OS process Multitasking version of JVM OS-style multitasking 12/02/2004 CS 5204 - Fall 2004
Separate VMs Advantages Disadvantages Fault isolation Higher Programmer productivity Disadvantages Inefficient resource utilization Downgraded performance Poor scalability Poor application startup time 12/02/2004 CS 5204 - Fall 2004
MVM Applications are protected from each other Multitasking features TASKS Multitasking features Safe Secure Scalable NO COMPROMISE approach 12/02/2004 CS 5204 - Fall 2004
MVM Goals Just like those of an OS No interference JVM illusion Perform and scale well Just like those of an OS 12/02/2004 CS 5204 - Fall 2004
Design decisions Examine each component Changes to JVM Shareable Non-Shareable… replicate Changes to JVM No bytecode editing Separate task data sets End task at any time 12/02/2004 CS 5204 - Fall 2004
MVM Design Lightweight Isolation Memory Management User-Level Native Code 12/02/2004 CS 5204 - Fall 2004
Lightweight Isolation Share as much as possible Replicate everything else Issues Class Initialization Accessing appropriate copy Efficient retrieval Making it scalable 12/02/2004 CS 5204 - Fall 2004
In MVM 12/02/2004 CS 5204 - Fall 2004
Class Initialization Different from object initialization Done by <clinit> class ClassInitialization { static int first = 3; static int second = 1 + first; public static void main (String [] args) { X.y++; } } class X { static { System.out.println("Hello World"); } static int y; 0 iconst_3 1 putstatic ClassInitialization/first I 4 iconst_1 5 getstatic ClassInitialization/first I 8 iadd 9 putstatic ClassInitialization/secondI 12/02/2004 CS 5204 - Fall 2004
Loading and Linking Loading Linking Create main memory representation Create TCM Add static variables Mark “loaded” Linking Verify class Check loader constraints Build constant pool cache 12/02/2004 CS 5204 - Fall 2004
Dynamic code rewriting Class initialization barrier Check for entry in TCM table Once per task Necessitates two entries Link resolution barrier Unchanged from JVM 12/02/2004 CS 5204 - Fall 2004
Other issues Quickened bytecodes Sharing Complied Code Re-introduce barriers Affects only four methods Sharing Complied Code Native code for method Patching stubs Class initialization barriers 12/02/2004 CS 5204 - Fall 2004
Performance – Memory footprint 12/02/2004 CS 5204 - Fall 2004
Performance – Time overheads 12/02/2004 CS 5204 - Fall 2004
Memory Management Heap Memory Mechanisms Surplus memory management Memory accountability Per-task Garbage Collections 12/02/2004 CS 5204 - Fall 2004
In HSVM New Generation Old Generation Eden Aging For new objects Aging From-space Objects garbage collected (GC) To-space Old Generation Collection triggered when filled up 12/02/2004 CS 5204 - Fall 2004
In MVM Old generation shared New generation common More activities occur here Eliminates heap-related interference 12/02/2004 CS 5204 - Fall 2004
Surplus Memory Management Postpone or avoid GC Given to new generation Handled by New Space Manager (NSM) 12/02/2004 CS 5204 - Fall 2004
Memory Accounting 12/02/2004 CS 5204 - Fall 2004
Performance – Memory Management Overheads Replicated new generation Memory accounting Extending eden and book-keeping Conclusion Execution time benefits from larger eden 12/02/2004 CS 5204 - Fall 2004
Handling Native Code Isolation layer Native library replicated Redefines functions to include arguments 12/02/2004 CS 5204 - Fall 2004
My evaluation - pros MVM is a complete system Appears just like a JVM for apps Provides excellent multitasking features Safe Secure Scalable 12/02/2004 CS 5204 - Fall 2004
My evaluation - cons One app can crash the VM When interaction is required, costly local RPC needed GC forced by one task can interfere with another task’s performance It does compromise! 12/02/2004 CS 5204 - Fall 2004
Questions? 12/02/2004 CS 5204 - Fall 2004