290 likes | 412 Vues
Unpicking The Knot : Teasing Apart VM/Application Interdependencies. Yi Lin, Steve Blackburn, Daniel Frampton The Australian National University. Introduction. Introduction. Understanding VMs is important. Resource Management Security Performance / Profiling Unfortunately this is hard!
E N D
Unpicking The Knot:Teasing Apart VM/Application Interdependencies Yi Lin, Steve Blackburn, Daniel Frampton The Australian National University
Introduction Unpicking the knot | Lin, Blackburn and Frampton
Introduction Understanding VMs is important • Resource Management • Security • Performance/Profiling Unfortunately this is hard! VMs are complex.HotSpot (~250,000LOC) [1] Ogata et al. [OOPSLA’10] [2] Eeckhout et al. [OOPSLA’03] Unpicking the knot | Lin, Blackburn and Frampton
Introduction Hardware Is Getting More Complex! • Goal: reliable, portable software • Confounded by h/w complexity • High-level language • Abstraction • Safety • Productivity Unpicking the knot | Lin, Blackburn and Frampton
Introduction Metacircularity • Potential consequence when we choose a high level language • Language runtime depends on itself • PyPy (Python / Python) • Singluarity (C# / C#) • JikesRVM (Java / Java) Opinion: Metacircularity is not a meaningful end,but it may be a natural choice Unpicking the knot | Lin, Blackburn and Frampton
Introduction Unclear VM/APP Context • Metacircular runtime can re-enter itself • Ambiguous static context Application Application Language Library VM VM HashMap Classloader MM Allocation for VM or App? Unpicking the knot | Lin, Blackburn and Frampton
Introduction VM/APP Inter-dependency • VM/APP tangled like a knot • Contextual Ambiguity • VM? • Application? Unpicking the knot | Lin, Blackburn and Frampton
Introduction Tease Apart Interdependencies We propose a low-overhead framework to • Track dynamic context • Maximize static context clarity We use metacircular implementation • Problem is most vivid there Unpicking the knot | Lin, Blackburn and Frampton
Tracking ContextContext, Transition Point, Runtime Service Unpicking the knot | Lin, Blackburn and Frampton
Tracking Context OS Analogy? • Kernel/User User Kernel • Binary divide: kernel/user • Crisply defined boundary • Explicit transitions How much of what we learn from OS can be applied to VM? Unpicking the knot | Lin, Blackburn and Frampton
Tracking Context Binary Context? • Binary context divide (VM/APP): insufficient • Re-entrancy • Application needs classloading • actual downcall • Classloader needs Allocation • reentry, but essential • Allocator needs allocation • infinite regression ✗ Unpicking the knot | Lin, Blackburn and Frampton
Tracking Context Dynamic Context • Detailed contexts: holding runtime request • Rules:Context as DAG Unpicking the knot | Lin, Blackburn and Frampton
Tracking Context Context Transition Point Methods where context transition occurs Unpicking the knot | Lin, Blackburn and Frampton
Tracking Context Context Transition Points (cont.) Dynamic switching • switchContextTo(VM) in the beginning • switchContextBack(oldContext) in the end @DownCall(Context=Classloader) public synchronized void resolve() { /* original code */ } public synchronized void resolve() { intold = switchContextTo(Context.Classloader) try{ /*original code*/ } finally{ switchContextBack(old); } } • switchContextTo(Context.Classloader); • switchContextBack(old); Unpicking the knot | Lin, Blackburn and Frampton
Tracking Context Dependency Between Contexts ‘Substantive’ vs. lightweight publicclassRVMClass { privatebytestate; ... public synchronized void resolve() { ... // heavyweight resolving code state = CLASS_RESOLVED; } @Inline public booleanisResolved(){ returnstate >= CLASS_RESOLVED; } } Substantive dependency Context Transition • @DownCall(Context=Classloader) Lightweight dependency @RuntimeService No Context Transition • @RuntimeService Unpicking the knot | Lin, Blackburn and Frampton
Tracking Context @RuntimeService • Allow lightweight code run out of context • Fastpath (alloc/wb/etc) is @RuntimeService • Reasonable choice for better performance • Properly track current context (request) • Avoid a large number of unnecessary context transitions • Impedance matching • DRLVM(C++) implements service code in Java Unpicking the knot | Lin, Blackburn and Frampton
Tracking Context Transition Point Placement • Consideration to transitions when designing new VMs • VM-Application interface • VM-Library interface • Modular design for VM components • Identifying transitions in existing VMs • Experimental approach • @AssertExecutionContext to dump stack Unpicking the knot | Lin, Blackburn and Frampton
Tracking Context Transition Point Placement (cont.) Example : new() DownCall -- Stack –- at Lorg/mmtk/policy/Space; acquire at Lorg/mmtk/utility/alloc/BumpPointer; allocSlow at Lorg/mmtk/utility/alloc/BumpPointer;alloc … at Lorg/jikesrvm/mm/mminterface/MemoryManager; resolvedNewScalar at Lavrora/sim/clock/RippleSynchronizer; advance at Lavrora/sim/clock/RippleSynchronizer; waitForNeighbors at Lavrora/sim/radio/Medium$Receiver; waitForNeighbors -- Stack -- at Lorg/mmtk/policy/Space; acquire at Lorg/mmtk/utility/alloc/BumpPointer; allocSlow at Lorg/mmtk/utility/alloc/BumpPointer; alloc … at Lorg/jikesrvm/mm/mminterface/MemoryManager; resolvedNewScalar at Lavrora/sim/clock/RippleSynchronizer; advance at Lavrora/sim/clock/RippleSynchronizer; waitForNeighbors at Lavrora/sim/radio/Medium$Receiver; waitForNeighbors MM ~ ? Service code APP @Inline Fast path Lightweight operations Always gets executed @NoInline Slow path Heavy-weight ‘substantive’ ~0.1% chance of being executed Unpicking the knot | Lin, Blackburn and Frampton
publicclassBumpPointerSpace{ ... @DownCall(Context=MemoryManager) @NoInline public Address allocSlow(intbytes) { /* slow path */ } ... Tracking Context Refactoring @RuntimeServices @RuntimeService publicclassBumpPointer { ... @Inline public Address alloc(intbytes) { /* fast path */ } } publicclassBumpPointer { ... @Inline public Address alloc(intbytes) { /* fast path */ } @NoInline public Address allocSlow(intbytes) { /* slow path */ } } • @RuntimeService @Inline publicAddress alloc(intbytes) { /* fast path */ } • @DownCall(Context=MemoryManager) @NoInline publicAddress allocSlow(intbytes) { /* slow path */ } Unpicking the knot | Lin, Blackburn and Frampton
Tracking Context Refactored VM Application Language Library VM Classloader MM Compiler …… Service / Context ambiguous area Code that has specific context Unpicking the knot | Lin, Blackburn and Frampton
Tracking Context Service Unpicking the Knot Statically VM? Application? VM VM Application At any given time Application Unpicking the knot | Lin, Blackburn and Frampton
Tracking Context Performance • Low transition frequency: 10-850/ms • Low overhead: 0.6% slower • Prototype on JikesRVM • DaCapo + SpecJVM98 Unpicking the knot | Lin, Blackburn and Frampton
ResultsPerformance, use cases Unpicking the knot | Lin, Blackburn and Frampton
Results Use cases • Profiling • CPU cycles in different contexts • Allocation volume • Object survival ratio • Resource management • Heap footprint Unpicking the knot | Lin, Blackburn and Frampton
Results Allocation in contexts Application Compiler Booting Classloader Other Runtime Unpicking the knot | Lin, Blackburn and Frampton
Results Survival ratio in contexts Fraction of objects that can survive first gc Unpicking the knot | Lin, Blackburn and Frampton
Results Survival ratio in contexts (cont.) x axis is benchmarks These suggest we could use different heap/mm policy for different contexts Unpicking the knot | Lin, Blackburn and Frampton
Results Memory footprint 43.3% by Application, 56.7% by VM Unpicking the knot | Lin, Blackburn and Frampton
Summary • Understanding VM/APP is important • benefits, difficulties, our goal • Tracking context & Results • context, transition point, runtime service, low overhead, use cases • Conclusion • metacircular VMs closer to product quality • better insight for designing regular VMs Unpicking the knot | Lin, Blackburn and Frampton