Re: [rvm-research] Missing pickAllocator() call
Ruben Peter Vervaeke <[email protected]> Wed, 15 Aug 2018 18:26:36 +0000
| Newsgroups | gmane.comp.java.jikes.rvm.devel |
|---|---|
| Message-ID | <DB7PR01MB4235EFCD13B16376120813BEB73F0@DB7PR01MB4235.eurprd01.prod.exchangelabs.com> |
Hi Robin and Michael, You are both correct. I investigated further and also put print statements at the start of the method pickAllocatorForType(RVMType type). When the Example class is first encountered it is still unresolved. After it has been resolved the pickAllocatorForType(RVMType type) is called to choose an allocator for that type. So in that first case I don't have the context of the enclosing RVMMethod. I'll check Robin's suggestion to pass along the enclosing method information for an unresolved type somehow. Thank you for the explanation. Best regards Ruben This is the output with traceAllocator on: ... allocator for type LApp;: 0 allocator for LApp; | method LApp;.main ([Ljava/lang/String;)V: 0 Invoking instantiateHighlyWrittenObjects... allocator for Lgnu/java/net/loader/JarURLResource;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for type LExample;: 0 allocator for LExample;: 0 Creating Example object... allocator for LExample;: 0 Creating Example object... allocator for LExample;: 0 Creating Example object... Invoking instantiateHighlyWrittenObjects done Invoking instantiateMediumWrittenObjects... allocator for LExample; | method LApp;.instantiateMediumWrittenObjects ()V: allocator for [Ljava/lang/Class;: 0 allocator for type Ljava/lang/reflect/VMProxy;: 0 allocator for Ljava/util/HashMap;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for type Ljava/lang/reflect/Modifier;: 0 allocator for type Lorg/jikesrvm/classloader/ReflectionBase$$Reflect1547;: 0 allocator for Lorg/jikesrvm/classloader/ReflectionBase$$Reflect1547;: 0 allocator for type Lorg/jikesrvm/classloader/ReflectionBase$$Reflect1191;: 0 allocator for Lorg/jikesrvm/classloader/ReflectionBase$$Reflect1191;: 0 allocator for type Lorg/jikesrvm/classloader/ReflectionBase$$Reflect1192;: 0 allocator for Lorg/jikesrvm/classloader/ReflectionBase$$Reflect1192;: 0 allocator for type Lorg/jikesrvm/classloader/ReflectionBase$$Reflect1193;: 0 allocator for Lorg/jikesrvm/classloader/ReflectionBase$$Reflect1193;: 0 allocator for type Lorg/jikesrvm/classloader/ReflectionBase$$Reflect1194;: 0 allocator for Lorg/jikesrvm/classloader/ReflectionBase$$Reflect1194;: 0 allocator for type Lorg/jikesrvm/classloader/ReflectionBase$$Reflect4633;: 0 allocator for Lorg/jikesrvm/classloader/ReflectionBase$$Reflect4633;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for type L$Proxy0;: 0 allocator for type Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39945;: 0 allocator for Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39945;: 0 allocator for L$Proxy0;: 0 Found AllocationStrategy on method: instantiateMediumWrittenObjects MutationRate: MID DEFAULT_DRAM Creating Example object... Creating Example object... Creating Example object... Invoking instantiateMediumWrittenObjects done Invoking instantiateNoneWrittenObjects... allocator for LExample; | method LApp;.instantiateNoneWrittenObjects ()V: allocator for [Ljava/lang/Class;: 0 allocator for L$Proxy0;: 0 Found AllocationStrategy on method: instantiateNoneWrittenObjects MutationRate: NONE DEFAULT_NVM Creating Example object... Creating Example object... Creating Example object... Invoking instantiateNoneWrittenObjects done And this is the output when an initial Example object is created before calling the first 'instantiate'-method: ... allocator for type LApp;: 0 allocator for LApp; | method LApp;.main ([Ljava/lang/String;)V: 0 Creating initial Example object... allocator for Lgnu/java/net/loader/JarURLResource;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for type LExample;: 0 allocator for LExample;: 0 Creating Example object... Invoking instantiateHighlyWrittenObjects... allocator for LExample; | method LApp;.instantiateHighlyWrittenObjects ()V: allocator for [Ljava/lang/Class;: 0 allocator for type Ljava/lang/reflect/VMProxy;: 0 allocator for Ljava/util/HashMap;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for type Ljava/lang/reflect/Modifier;: 0 allocator for type Lorg/jikesrvm/classloader/ReflectionBase$$Reflect1547;: 0 allocator for Lorg/jikesrvm/classloader/ReflectionBase$$Reflect1547;: 0 allocator for type Lorg/jikesrvm/classloader/ReflectionBase$$Reflect1191;: 0 allocator for Lorg/jikesrvm/classloader/ReflectionBase$$Reflect1191;: 0 allocator for type Lorg/jikesrvm/classloader/ReflectionBase$$Reflect1192;: 0 allocator for Lorg/jikesrvm/classloader/ReflectionBase$$Reflect1192;: 0 allocator for type Lorg/jikesrvm/classloader/ReflectionBase$$Reflect1193;: 0 allocator for Lorg/jikesrvm/classloader/ReflectionBase$$Reflect1193;: 0 allocator for type Lorg/jikesrvm/classloader/ReflectionBase$$Reflect1194;: 0 allocator for Lorg/jikesrvm/classloader/ReflectionBase$$Reflect1194;: 0 allocator for type Lorg/jikesrvm/classloader/ReflectionBase$$Reflect4633;: 0 allocator for Lorg/jikesrvm/classloader/ReflectionBase$$Reflect4633;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for Ljava/lang/ref/WeakReference;: 0 allocator for type L$Proxy0;: 0 allocator for type Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39945;: 0 allocator for Lorg/jikesrvm/classloader/ReflectionBase$$Reflect39945;: 0 allocator for L$Proxy0;: 0 Found AllocationStrategy on method: instantiateHighlyWrittenObjects MutationRate: HIGH DEFAULT_DRAM Creating Example object... Creating Example object... Creating Example object... Invoking instantiateHighlyWrittenObjects done Invoking instantiateMediumWrittenObjects... allocator for LExample; | method LApp;.instantiateMediumWrittenObjects ()V: allocator for [Ljava/lang/Class;: 0 allocator for L$Proxy0;: 0 Found AllocationStrategy on method: instantiateMediumWrittenObjects MutationRate: MID DEFAULT_DRAM Creating Example object... Creating Example object... Creating Example object... Invoking instantiateMediumWrittenObjects done Invoking instantiateNoneWrittenObjects... allocator for LExample; | method LApp;.instantiateNoneWrittenObjects ()V: allocator for [Ljava/lang/Class;: 0 allocator for L$Proxy0;: 0 Found AllocationStrategy on method: instantiateNoneWrittenObjects MutationRate: NONE DEFAULT_NVM Creating Example object... Creating Example object... Creating Example object... Invoking instantiateNoneWrittenObjects done ________________________________ Van: Michael Bond <[email protected]> Verzonden: woensdag 15 augustus 2018 16:29:25 Aan: [email protected] Onderwerp: Re: [rvm-research] Missing pickAllocator() call Hi Ruben, I suspect it's related to resolved vs. unresolved types. When instantiateHighlyWrittenObjects() gets called, it first gets JIT-compiled, and at that point Example hasn't been resolved. When instantiateMediumWrittenObjects() gets called, it first gets JIT-compiled, but by that point Example has been resolved. I don't remember the code related to pickAllocator, but I'd suggest checking to make sure you're handling not only the cases for resolved types but also for unresolved types. And/or you can test my theory by allocating an instance of Example in main() before calling instantiateHighlyWrittenObjects(). Cheers, Mike On 08/14/2018 12:31 PM, Ruben Peter Vervaeke wrote: Hi, I am writing a small application to test the workings of my rvm implementation. It contains 3 methods that are called in turn. Each method is annotated with an AllocationStrategy annotation. This annotation is checked in the pickAllocator(RVMType type, RVMMethod method) method of the MemoryManager class for determining an appropriate allocator. Unfortunately when I run my application the pickAllocator(...) method doesn't find the annotation for the very first method. All subsequent method calls are in fact good, in the sense that the AllocationStrategy annotation is found on the methods. I have debugged this and found that the pickAllocator(RVMType type, RVMMethod method) method is simply not called for the first method. I don't understand why. Does anyone knows why this is happening? If so, any idea how to fix this? Thanks in advance Ruben App.java public class App { public static void main(String[] args) throws InterruptedException { App app = new App(); System.out.println("Invoking instantiateHighlyWrittenObjects..."); app.instantiateHighlyWrittenObjects(); System.out.println("Invoking instantiateHighlyWrittenObjects done"); System.out.println("Invoking instantiateMediumWrittenObjects..."); app.instantiateMediumWrittenObjects(); System.out.println("Invoking instantiateMediumWrittenObjects done"); System.out.println("Invoking instantiateNoneWrittenObjects..."); app.instantiateNoneWrittenObjects(); System.out.println("Invoking instantiateNoneWrittenObjects done"); // Force GC System.gc(); } @AllocationStrategy(mutationRate = AllocationStrategy.MutationRate.HIGH) public void instantiateHighlyWrittenObjects() { for (int i = 0; i < 3; i++) { Example o = new Example(); } } @AllocationStrategy(mutationRate = AllocationStrategy.MutationRate.MID) public void instantiateMediumWrittenObjects() { for (int i = 0; i < 3; i++) { Example o = new Example(); } } @AllocationStrategy(mutationRate = AllocationStrategy.MutationRate.NONE) public void instantiateNoneWrittenObjects() { for (int i = 0; i < 3; i++) { Example o = new Example(); } } } MemoryManager.java @Uninterruptible public final class MemoryManager { ... @Interruptible public static int pickAllocator(RVMType type, RVMMethod method) { if (traceAllocator) { VM.sysWrite("allocator for "); VM.sysWrite(type.getDescriptor()); VM.sysWrite(": "); } if (method != null) { // We should strive to be allocation-free here. RVMClass cls = method.getDeclaringClass(); byte[] clsBA = cls.getDescriptor().toByteArray(); if (Selected.Constraints.get().withGCspy()) { if (isPrefix("Lorg/mmtk/vm/gcspy/", clsBA) || isPrefix("[Lorg/mmtk/vm/gcspy/", clsBA)) { if (traceAllocator) { VM.sysWriteln("GCSPY"); } return Plan.ALLOC_GCSPY; } } if (method.getName().toString().startsWith("instantiate")) { VM.sysWriteln("Checking AllocationStrategy on method: " + method.getName()); } AllocationStrategy allocationStrategy = method.getAllocationStrategy(); if (allocationStrategy != null) { if (traceASAllocator) { VM.sysWriteln("Found AllocationStrategy on method: " + method.getName()); } AllocationStrategy.MutationRate mutationRate = allocationStrategy.mutationRate(); if (traceASAllocator) { VM.sysWriteln("MutationRate: " + mutationRate.name()); } switch (mutationRate) { case NONE: if (traceAllocator || traceASAllocator) { VM.sysWriteln("DEFAULT_NVM"); } return Plan.ALLOC_DEFAULT_NVM; default: if (traceAllocator || traceASAllocator) { VM.sysWriteln("DEFAULT_DRAM"); } return Plan.ALLOC_DEFAULT_DRAM; } } if (isPrefix("Lorg/jikesrvm/mm/mmtk/ReferenceProcessor", clsBA)) { if (traceAllocator) { VM.sysWriteln("DEFAULT"); } return Plan.ALLOC_DEFAULT_DRAM; } if (isPrefix("Lorg/mmtk/", clsBA) || isPrefix("Lorg/jikesrvm/mm/", clsBA)) { if (traceAllocator) { VM.sysWriteln("NONMOVING"); } return Plan.ALLOC_NON_MOVING; } if (method.isNonMovingAllocation()) { return Plan.ALLOC_NON_MOVING; } } if (traceAllocator) { VM.sysWriteln(type.getMMAllocator()); } return type.getMMAllocator(); } ... } Output when run: rvervaek@rvervaek-VirtualBox:~/IdeaProjects/jikesrvm-as$ ./dist/production_x86_64-linux/rvm -Xms80M -X:gc:boundedNursery=4M -X:gc:variableSizeHeap=false -Dprobes=Replay,MMTk -X:aos:initial_compiler=base -X:aos:enable_bulk_compile=true -X:aos:enable_recompilation=false -X:availableProcessors=4 -X:gc:threads=2 -cp /home/rvervaek/Artifacts/as-method.jar App Invoking instantiateHighlyWrittenObjects... Creating Example object... Creating Example object... Creating Example object... Invoking instantiateHighlyWrittenObjects done Invoking instantiateMediumWrittenObjects... Checking AllocationStrategy on method: instantiateMediumWrittenObjects Found AllocationStrategy on method: instantiateMediumWrittenObjects MutationRate: MID DEFAULT_DRAM Creating Example object... Creating Example object... Creating Example object... Invoking instantiateMediumWrittenObjects done Invoking instantiateNoneWrittenObjects... Checking AllocationStrategy on method: instantiateNoneWrittenObjects Found AllocationStrategy on method: instantiateNoneWrittenObjects MutationRate: NONE DEFAULT_NVM Creating Example object... Creating Example object... Creating Example object... Invoking instantiateNoneWrittenObjects done ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Jikesrvm-researchers mailing list [email protected]<mailto:[email protected]> https://lists.sourceforge.net/lists/listinfo/jikesrvm-researchers ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Jikesrvm-researchers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jikesrvm-researchers