Re: [rvm-research] Missing pickAllocator() call
Michael Bond <[email protected]> Wed, 15 Aug 2018 10:29:25 -0400
| Newsgroups | gmane.comp.java.jikes.rvm.devel |
|---|---|
| Message-ID | <[email protected]> |
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]
> 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