< prev index next >

src/share/vm/gc_implementation/shared/ageTable.cpp

Print this page




   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc_implementation/shared/ageTable.hpp"

  27 #include "gc_implementation/shared/gcPolicyCounters.hpp"
  28 #include "memory/collectorPolicy.hpp"
  29 #include "memory/resourceArea.hpp"
  30 #include "memory/sharedHeap.hpp"
  31 #include "utilities/copy.hpp"
  32 
  33 /* Copyright (c) 1992-2009 Oracle and/or its affiliates, and Stanford University.
  34    See the LICENSE file for license information. */
  35 
  36 ageTable::ageTable(bool global) {
  37 
  38   clear();
  39 
  40   if (UsePerfData && global) {
  41 
  42     ResourceMark rm;
  43     EXCEPTION_MARK;
  44 
  45     const char* agetable_ns = "generation.0.agetable";
  46     const char* bytes_ns = PerfDataManager::name_space(agetable_ns, "bytes");


  61 }
  62 
  63 void ageTable::clear() {
  64   for (size_t* p = sizes; p < sizes + table_size; ++p) {
  65     *p = 0;
  66   }
  67 }
  68 
  69 void ageTable::merge(ageTable* subTable) {
  70   for (int i = 0; i < table_size; i++) {
  71     sizes[i]+= subTable->sizes[i];
  72   }
  73 }
  74 
  75 void ageTable::merge_par(ageTable* subTable) {
  76   for (int i = 0; i < table_size; i++) {
  77     Atomic::add_ptr(subTable->sizes[i], &sizes[i]);
  78   }
  79 }
  80 
  81 uint ageTable::compute_tenuring_threshold(size_t survivor_capacity) {
  82   size_t desired_survivor_size = (size_t)((((double) survivor_capacity)*TargetSurvivorRatio)/100);
  83   size_t total = 0;
  84   uint age = 1;
  85   assert(sizes[0] == 0, "no objects with age zero should be recorded");
  86   while (age < table_size) {
  87     total += sizes[age];
  88     // check if including objects of age 'age' made us pass the desired
  89     // size, if so 'age' is the new threshold
  90     if (total > desired_survivor_size) break;
  91     age++;
  92   }
  93   uint result = age < MaxTenuringThreshold ? age : MaxTenuringThreshold;
  94 
  95   if (PrintTenuringDistribution || UsePerfData) {
  96 
  97     if (PrintTenuringDistribution) {
  98       gclog_or_tty->cr();
  99       gclog_or_tty->print_cr("Desired survivor size " SIZE_FORMAT " bytes, new threshold %u (max %u)",
 100         desired_survivor_size*oopSize, result, (int) MaxTenuringThreshold);
 101     }
 102 
 103     total = 0;
 104     age = 1;
 105     while (age < table_size) {
 106       total += sizes[age];
 107       if (sizes[age] > 0) {
 108         if (PrintTenuringDistribution) {
 109           gclog_or_tty->print_cr("- age %3u: " SIZE_FORMAT_W(10) " bytes, " SIZE_FORMAT_W(10) " total",
 110                                         age,    sizes[age]*oopSize,          total*oopSize);
 111         }
 112       }

 113       if (UsePerfData) {
 114         _perf_sizes[age]->set_value(sizes[age]*oopSize);
 115       }
 116       age++;
 117     }
 118     if (UsePerfData) {
 119       SharedHeap* sh = SharedHeap::heap();
 120       CollectorPolicy* policy = sh->collector_policy();
 121       GCPolicyCounters* gc_counters = policy->counters();
 122       gc_counters->tenuring_threshold()->set_value(result);
 123       gc_counters->desired_survivor_size()->set_value(
 124         desired_survivor_size*oopSize);
 125     }
 126   }
 127 
 128   return result;
 129 }


   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc_implementation/shared/ageTable.hpp"
  27 #include "gc_implementation/shared/ageTableTracer.hpp"
  28 #include "gc_implementation/shared/gcPolicyCounters.hpp"
  29 #include "memory/collectorPolicy.hpp"
  30 #include "memory/resourceArea.hpp"
  31 #include "memory/sharedHeap.hpp"
  32 #include "utilities/copy.hpp"
  33 
  34 /* Copyright (c) 1992-2009 Oracle and/or its affiliates, and Stanford University.
  35    See the LICENSE file for license information. */
  36 
  37 ageTable::ageTable(bool global) {
  38 
  39   clear();
  40 
  41   if (UsePerfData && global) {
  42 
  43     ResourceMark rm;
  44     EXCEPTION_MARK;
  45 
  46     const char* agetable_ns = "generation.0.agetable";
  47     const char* bytes_ns = PerfDataManager::name_space(agetable_ns, "bytes");


  62 }
  63 
  64 void ageTable::clear() {
  65   for (size_t* p = sizes; p < sizes + table_size; ++p) {
  66     *p = 0;
  67   }
  68 }
  69 
  70 void ageTable::merge(ageTable* subTable) {
  71   for (int i = 0; i < table_size; i++) {
  72     sizes[i]+= subTable->sizes[i];
  73   }
  74 }
  75 
  76 void ageTable::merge_par(ageTable* subTable) {
  77   for (int i = 0; i < table_size; i++) {
  78     Atomic::add_ptr(subTable->sizes[i], &sizes[i]);
  79   }
  80 }
  81 
  82 uint ageTable::compute_tenuring_threshold(size_t survivor_capacity, GCTracer &tracer) {
  83   size_t desired_survivor_size = (size_t)((((double) survivor_capacity)*TargetSurvivorRatio)/100);
  84   size_t total = 0;
  85   uint age = 1;
  86   assert(sizes[0] == 0, "no objects with age zero should be recorded");
  87   while (age < table_size) {
  88     total += sizes[age];
  89     // check if including objects of age 'age' made us pass the desired
  90     // size, if so 'age' is the new threshold
  91     if (total > desired_survivor_size) break;
  92     age++;
  93   }
  94   uint result = age < MaxTenuringThreshold ? age : MaxTenuringThreshold;
  95 
  96   if (PrintTenuringDistribution || UsePerfData || AgeTableTracer::is_tenuring_distribution_event_enabled()) {
  97 
  98     if (PrintTenuringDistribution) {
  99       gclog_or_tty->cr();
 100       gclog_or_tty->print_cr("Desired survivor size " SIZE_FORMAT " bytes, new threshold %u (max %u)",
 101         desired_survivor_size*oopSize, result, (int) MaxTenuringThreshold);
 102     }
 103 
 104     total = 0;
 105     age = 1;
 106     while (age < table_size) {
 107       total += sizes[age];
 108       if (sizes[age] > 0) {
 109         if (PrintTenuringDistribution) {
 110           gclog_or_tty->print_cr("- age %3u: " SIZE_FORMAT_W(10) " bytes, " SIZE_FORMAT_W(10) " total",
 111                                         age,    sizes[age]*oopSize,          total*oopSize);
 112         }
 113       }
 114       AgeTableTracer::send_tenuring_distribution_event(age, wordSize * oopSize, tracer);
 115       if (UsePerfData) {
 116         _perf_sizes[age]->set_value(sizes[age]*oopSize);
 117       }
 118       age++;
 119     }
 120     if (UsePerfData) {
 121       SharedHeap* sh = SharedHeap::heap();
 122       CollectorPolicy* policy = sh->collector_policy();
 123       GCPolicyCounters* gc_counters = policy->counters();
 124       gc_counters->tenuring_threshold()->set_value(result);
 125       gc_counters->desired_survivor_size()->set_value(
 126         desired_survivor_size*oopSize);
 127     }
 128   }
 129 
 130   return result;
 131 }
< prev index next >