src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp

changeset 1
2d8a650513c2
parent 0
f90c822e73f8
child 25
873fd82b133d
     1.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp	Wed Apr 27 01:25:04 2016 +0800
     1.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp	Fri Apr 29 00:06:10 2016 +0800
     1.3 @@ -22,6 +22,12 @@
     1.4   *
     1.5   */
     1.6  
     1.7 +/*
     1.8 + * This file has been modified by Loongson Technology in 2015. These
     1.9 + * modifications are Copyright (c) 2015 Loongson Technology, and are made
    1.10 + * available on the same license terms set forth above.
    1.11 + */
    1.12 +
    1.13  #include "precompiled.hpp"
    1.14  #include "classfile/symbolTable.hpp"
    1.15  #include "code/codeCache.hpp"
    1.16 @@ -38,6 +44,7 @@
    1.17  #include "gc_implementation/shared/gcTrace.hpp"
    1.18  #include "gc_implementation/shared/gcTraceTime.hpp"
    1.19  #include "gc_implementation/shared/isGCActiveMark.hpp"
    1.20 +#include "gc_implementation/shared/mutableNUMASpace.hpp"
    1.21  #include "gc_implementation/shared/spaceDecorator.hpp"
    1.22  #include "gc_interface/gcCause.hpp"
    1.23  #include "memory/collectorPolicy.hpp"
    1.24 @@ -230,8 +237,15 @@
    1.25    IsGCActiveMark mark;
    1.26  
    1.27    const bool scavenge_done = PSScavenge::invoke_no_policy();
    1.28 -  const bool need_full_gc = !scavenge_done ||
    1.29 -    policy->should_full_GC(heap->old_gen()->free_in_bytes());
    1.30 +  bool need_full_gc;
    1.31 +  if(UseOldNUMA) {
    1.32 +    need_full_gc = !scavenge_done ||
    1.33 +      policy->should_full_GC(heap->old_gen()->free_in_bytes_numa());
    1.34 +  }
    1.35 +  else {
    1.36 +    need_full_gc = !scavenge_done ||
    1.37 +      policy->should_full_GC(heap->old_gen()->free_in_bytes());
    1.38 +  }
    1.39    bool full_gc_done = false;
    1.40  
    1.41    if (UsePerfData) {
    1.42 @@ -255,6 +269,30 @@
    1.43    return full_gc_done;
    1.44  }
    1.45  
    1.46 +/* 2014/7/7 Liao: Add these variables to stastic detail information during GC. */
    1.47 +/* Used for objects copy stastic. */
    1.48 +float each_gc_copy_time[16];
    1.49 +int   each_gc_copy_fre[16];
    1.50 +
    1.51 +/* Used for GC details stastic. */
    1.52 +float total_gc_time = 0;
    1.53 +int   total_gc_fre  = 0;
    1.54 +
    1.55 +/* Used to statstic ThreadRoots optimization. */
    1.56 +int task_tag[16];
    1.57 +//Used to stastic each cpu
    1.58 +int each_total_num[16];
    1.59 +int each_eden_total_num[3][16];
    1.60 +int each_eden_aligned_num[3][16];
    1.61 +//Used to stastic every GC
    1.62 +int every_total_num;
    1.63 +int every_eden_total_num[3];
    1.64 +int every_eden_aligned_num[3];
    1.65 +//Used to stastic all the time
    1.66 +int all_total_num;
    1.67 +int all_eden_total_num[3];
    1.68 +int all_eden_aligned_num[3];
    1.69 +
    1.70  // This method contains no policy. You should probably
    1.71  // be calling invoke() instead.
    1.72  bool PSScavenge::invoke_no_policy() {
    1.73 @@ -308,6 +346,29 @@
    1.74      heap->record_gen_tops_before_GC();
    1.75    }
    1.76  
    1.77 +  if(UseStasticCopy) {
    1.78 +    for(uint i = 0; i < ParallelGCThreads; i++) {
    1.79 +      each_gc_copy_time[i] = 0;
    1.80 +      each_gc_copy_fre[i] = 0;
    1.81 +    }
    1.82 +  }
    1.83 +
    1.84 +  if(UseStasticScavenge) {
    1.85 +    for(int j = 0; j < 3; j++) {
    1.86 +      for(uint i = 0; i < ParallelGCThreads; i++) {
    1.87 +        task_tag[i] = 0;
    1.88 +
    1.89 +        each_total_num[i] = 0;
    1.90 +        each_eden_total_num[j][i] = 0;
    1.91 +        each_eden_aligned_num[j][i] = 0;
    1.92 +
    1.93 +        every_total_num = 0;
    1.94 +        every_eden_total_num[j]  = 0;
    1.95 +        every_eden_aligned_num[j] = 0;
    1.96 +      }
    1.97 +    }
    1.98 +  }
    1.99 +  
   1.100    heap->print_heap_before_gc();
   1.101    heap->trace_heap_before_gc(&_gc_tracer);
   1.102  
   1.103 @@ -402,12 +463,34 @@
   1.104  
   1.105        GCTaskQueue* q = GCTaskQueue::create();
   1.106  
   1.107 -      if (!old_gen->object_space()->is_empty()) {
   1.108 -        // There are only old-to-young pointers if there are objects
   1.109 -        // in the old gen.
   1.110 -        uint stripe_total = active_workers;
   1.111 -        for(uint i=0; i < stripe_total; i++) {
   1.112 -          q->enqueue(new OldToYoungRootsTask(old_gen, old_top, i, stripe_total));
   1.113 +      if(UseOldNUMA) {
   1.114 +        MutableSpace* sp;
   1.115 +        MutableNUMASpace::LGRPSpace *ls;
   1.116 +        MutableNUMASpace* s = (MutableNUMASpace*) old_gen->object_space();
   1.117 +        int i, j;
   1.118 +        i = s->lgrp_spaces()->length();
   1.119 +        HeapWord** gen_top = (HeapWord**) malloc (i * sizeof(HeapWord));
   1.120 +        for(j = 0; j < i; j++) {
   1.121 +          ls = s->lgrp_spaces()->at(j);
   1.122 +          sp = ls->space();
   1.123 +          *(gen_top + j) = sp->top();
   1.124 +        }
   1.125 +
   1.126 +        if (!old_gen->object_space()->is_empty()) {
   1.127 +          uint stripe_total = active_workers;
   1.128 +          for(uint i=0; i < stripe_total; i++) {
   1.129 +            q->enqueue(new OldToYoungRootsTask_OldNUMA(old_gen, gen_top, i, stripe_total));
   1.130 +          }
   1.131 +        }
   1.132 +      }
   1.133 +      else {
   1.134 +        if (!old_gen->object_space()->is_empty()) {
   1.135 +          // There are only old-to-young pointers if there are objects
   1.136 +          // in the old gen.
   1.137 +          uint stripe_total = active_workers;
   1.138 +          for(uint i=0; i < stripe_total; i++) {
   1.139 +            q->enqueue(new OldToYoungRootsTask(old_gen, old_top, i, stripe_total));
   1.140 +          }
   1.141          }
   1.142        }
   1.143  
   1.144 @@ -698,6 +781,56 @@
   1.145                    scavenge_exit.ticks());
   1.146      gc_task_manager()->print_task_time_stamps();
   1.147    }
   1.148 +   
   1.149 +  if(PrintGCDetails) {
   1.150 +    float young_gc_time;
   1.151 +    total_gc_fre++; 
   1.152 +    young_gc_time = ((float)(scavenge_exit.ticks() - scavenge_entry.ticks()))/1e9;
   1.153 +    total_gc_time = total_gc_time + ((float)(scavenge_exit.ticks() - scavenge_entry.ticks()))/1e9;
   1.154 +    tty->print_cr("total_gc_fre = %d, young_gc_time = %f, total_gc_time = %f", total_gc_fre, young_gc_time, total_gc_time);
   1.155 +  }
   1.156 +  
   1.157 +  if(UseStasticCopy) {
   1.158 +    for(uint i = 0; i < ParallelGCThreads; i++) {
   1.159 +      tty->print_cr("each_gc_copy_time[%d] = %f", i, each_gc_copy_time[i]/each_gc_copy_fre[i]);
   1.160 +    }
   1.161 +    tty->print_cr("");
   1.162 +    for(uint i = 0; i < ParallelGCThreads; i++) {
   1.163 +      tty->print_cr("each_gc_copy_fre[%d] = %d", i, each_gc_copy_fre[i]);
   1.164 +    }
   1.165 +  }
   1.166 +
   1.167 +  if(UseStasticScavenge) {
   1.168 +    for(int i = 0; i < 3; i++) {
   1.169 +      for(uint j = 0; j < ParallelGCThreads; j++) {
   1.170 +        every_eden_total_num[i] += each_eden_total_num[i][j];
   1.171 +        every_eden_aligned_num[i] += each_eden_aligned_num[i][j];
   1.172 +      }
   1.173 +    }
   1.174 +
   1.175 +    for(uint i = 0; i < ParallelGCThreads; i++) {
   1.176 +      every_total_num += each_total_num[i];
   1.177 +    }
   1.178 + 
   1.179 +    all_total_num += every_total_num;
   1.180 +
   1.181 +    for(int i = 0; i < 3; i++) {
   1.182 +      all_eden_total_num[i] +=  every_eden_total_num[i];
   1.183 +      all_eden_aligned_num[i] += every_eden_aligned_num[i];
   1.184 +    }
   1.185 +
   1.186 +    tty->print_cr("============= Every GCDetails: =============");
   1.187 +    tty->print_cr("ThreadRootTask: prop of all = %f, prop of aligned = %f", (float)every_eden_total_num[0]/(float)every_total_num, (float)every_eden_aligned_num[0]/(float)every_eden_total_num[0]);
   1.188 +    tty->print_cr("OldToYoungRootTask: prop of all = %f, prop of aligned = %f", (float)every_eden_total_num[1]/(float)every_total_num, (float)every_eden_aligned_num[1]/(float)every_eden_total_num[1]);
   1.189 +    tty->print_cr("StealTask: prop of all = %f, prop of aligned = %f", (float)every_eden_total_num[2]/(float)every_total_num, (float)every_eden_aligned_num[2]/(float)every_eden_total_num[2]);
   1.190 +    tty->print_cr("");
   1.191 +
   1.192 +    tty->print_cr("============= Total GCDetails: =============");
   1.193 +    tty->print_cr("ThreadRootTask: prop of all = %f, prop of aligned = %f", (float)all_eden_total_num[0]/(float)all_total_num, (float)all_eden_aligned_num[0]/(float)all_eden_total_num[0]);
   1.194 +    tty->print_cr("OldToYoungRootTask: prop of all = %f, prop of aligned = %f", (float)all_eden_total_num[1]/(float)all_total_num, (float)all_eden_aligned_num[1]/(float)all_eden_total_num[1]);
   1.195 +    tty->print_cr("StealTask: prop of all = %f, prop of aligned = %f", (float)all_eden_total_num[2]/(float)all_total_num, (float)all_eden_aligned_num[2]/(float)all_eden_total_num[2]);
   1.196 +    tty->print_cr("");
   1.197 +  }
   1.198  
   1.199  #ifdef TRACESPINNING
   1.200    ParallelTaskTerminator::print_termination_counts();

mercurial