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

Print this page




  26 #include "classfile/symbolTable.hpp"
  27 #include "classfile/systemDictionary.hpp"
  28 #include "code/codeCache.hpp"
  29 #include "gc_implementation/parallelScavenge/gcTaskManager.hpp"
  30 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.inline.hpp"
  31 #include "gc_implementation/parallelScavenge/pcTasks.hpp"
  32 #include "gc_implementation/parallelScavenge/psAdaptiveSizePolicy.hpp"
  33 #include "gc_implementation/parallelScavenge/psCompactionManager.inline.hpp"
  34 #include "gc_implementation/parallelScavenge/psMarkSweep.hpp"
  35 #include "gc_implementation/parallelScavenge/psMarkSweepDecorator.hpp"
  36 #include "gc_implementation/parallelScavenge/psOldGen.hpp"
  37 #include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
  38 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
  39 #include "gc_implementation/parallelScavenge/psScavenge.hpp"
  40 #include "gc_implementation/parallelScavenge/psYoungGen.hpp"
  41 #include "gc_implementation/shared/gcHeapSummary.hpp"
  42 #include "gc_implementation/shared/gcTimer.hpp"
  43 #include "gc_implementation/shared/gcTrace.hpp"
  44 #include "gc_implementation/shared/gcTraceTime.hpp"
  45 #include "gc_implementation/shared/isGCActiveMark.hpp"

  46 #include "gc_interface/gcCause.hpp"
  47 #include "memory/gcLocker.inline.hpp"
  48 #include "memory/referencePolicy.hpp"
  49 #include "memory/referenceProcessor.hpp"
  50 #include "oops/methodData.hpp"
  51 #include "oops/oop.inline.hpp"
  52 #include "oops/oop.pcgc.inline.hpp"
  53 #include "runtime/fprofiler.hpp"
  54 #include "runtime/safepoint.hpp"
  55 #include "runtime/vmThread.hpp"
  56 #include "services/management.hpp"
  57 #include "services/memoryService.hpp"
  58 #include "services/memTracker.hpp"
  59 #include "utilities/events.hpp"
  60 #include "utilities/stack.inline.hpp"
  61 
  62 #include <math.h>
  63 
  64 // All sizes are in HeapWords.
  65 const size_t ParallelCompactData::Log2RegionSize  = 16; // 64K words


2098     // Let the size policy know we're done
2099     size_policy->major_collection_end(old_gen->used_in_bytes(), gc_cause);
2100 
2101     if (UseAdaptiveSizePolicy) {
2102       if (PrintAdaptiveSizePolicy) {
2103         gclog_or_tty->print("AdaptiveSizeStart: ");
2104         gclog_or_tty->stamp();
2105         gclog_or_tty->print_cr(" collection: %d ",
2106                        heap->total_collections());
2107         if (Verbose) {
2108           gclog_or_tty->print("old_gen_capacity: %d young_gen_capacity: %d",
2109             old_gen->capacity_in_bytes(), young_gen->capacity_in_bytes());
2110         }
2111       }
2112 
2113       // Don't check if the size_policy is ready here.  Let
2114       // the size_policy check that internally.
2115       if (UseAdaptiveGenerationSizePolicyAtMajorCollection &&
2116           ((gc_cause != GCCause::_java_lang_system_gc) ||
2117             UseAdaptiveSizePolicyWithSystemGC)) {







2118         // Calculate optimal free space amounts
2119         assert(young_gen->max_size() >
2120           young_gen->from_space()->capacity_in_bytes() +
2121           young_gen->to_space()->capacity_in_bytes(),
2122           "Sizes of space in young gen are out-of-bounds");
2123 
2124         size_t young_live = young_gen->used_in_bytes();
2125         size_t eden_live = young_gen->eden_space()->used_in_bytes();
2126         size_t old_live = old_gen->used_in_bytes();
2127         size_t cur_eden = young_gen->eden_space()->capacity_in_bytes();
2128         size_t max_old_gen_size = old_gen->max_gen_size();
2129         size_t max_eden_size = young_gen->max_size() -
2130           young_gen->from_space()->capacity_in_bytes() -
2131           young_gen->to_space()->capacity_in_bytes();
2132 
2133         // Used for diagnostics
2134         size_policy->clear_generation_free_space_flags();
2135 
2136         size_policy->compute_generations_free_space(young_live,
2137                                                     eden_live,
2138                                                     old_live,
2139                                                     cur_eden,
2140                                                     max_old_gen_size,
2141                                                     max_eden_size,
2142                                                     true /* full gc*/);
2143 
2144         size_policy->check_gc_overhead_limit(young_live,
2145                                              eden_live,
2146                                              max_old_gen_size,
2147                                              max_eden_size,
2148                                              true /* full gc*/,
2149                                              gc_cause,
2150                                              heap->collector_policy());
2151 
2152         size_policy->decay_supplemental_growth(true /* full gc*/);
2153 
2154         heap->resize_old_gen(
2155           size_policy->calculated_old_free_size_in_bytes());
2156 
2157         // Don't resize the young generation at an major collection.  A
2158         // desired young generation size may have been calculated but
2159         // resizing the young generation complicates the code because the
2160         // resizing of the old generation may have moved the boundary
2161         // between the young generation and the old generation.  Let the
2162         // young generation resizing happen at the minor collections.
2163       }
2164       if (PrintAdaptiveSizePolicy) {
2165         gclog_or_tty->print_cr("AdaptiveSizeStop: collection: %d ",
2166                        heap->total_collections());
2167       }
2168     }
2169 
2170     if (UsePerfData) {
2171       PSGCAdaptivePolicyCounters* const counters = heap->gc_policy_counters();
2172       counters->update_counters();
2173       counters->update_old_capacity(old_gen->capacity_in_bytes());
2174       counters->update_young_capacity(young_gen->capacity_in_bytes());
2175     }
2176 
2177     heap->resize_all_tlabs();
2178 
2179     // Resize the metaspace capactiy after a collection
2180     MetaspaceGC::compute_new_size();
2181 
2182     if (TraceGen1Time) accumulated_time()->stop();




  26 #include "classfile/symbolTable.hpp"
  27 #include "classfile/systemDictionary.hpp"
  28 #include "code/codeCache.hpp"
  29 #include "gc_implementation/parallelScavenge/gcTaskManager.hpp"
  30 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.inline.hpp"
  31 #include "gc_implementation/parallelScavenge/pcTasks.hpp"
  32 #include "gc_implementation/parallelScavenge/psAdaptiveSizePolicy.hpp"
  33 #include "gc_implementation/parallelScavenge/psCompactionManager.inline.hpp"
  34 #include "gc_implementation/parallelScavenge/psMarkSweep.hpp"
  35 #include "gc_implementation/parallelScavenge/psMarkSweepDecorator.hpp"
  36 #include "gc_implementation/parallelScavenge/psOldGen.hpp"
  37 #include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
  38 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
  39 #include "gc_implementation/parallelScavenge/psScavenge.hpp"
  40 #include "gc_implementation/parallelScavenge/psYoungGen.hpp"
  41 #include "gc_implementation/shared/gcHeapSummary.hpp"
  42 #include "gc_implementation/shared/gcTimer.hpp"
  43 #include "gc_implementation/shared/gcTrace.hpp"
  44 #include "gc_implementation/shared/gcTraceTime.hpp"
  45 #include "gc_implementation/shared/isGCActiveMark.hpp"
  46 #include "gc_implementation/shared/spaceDecorator.hpp"
  47 #include "gc_interface/gcCause.hpp"
  48 #include "memory/gcLocker.inline.hpp"
  49 #include "memory/referencePolicy.hpp"
  50 #include "memory/referenceProcessor.hpp"
  51 #include "oops/methodData.hpp"
  52 #include "oops/oop.inline.hpp"
  53 #include "oops/oop.pcgc.inline.hpp"
  54 #include "runtime/fprofiler.hpp"
  55 #include "runtime/safepoint.hpp"
  56 #include "runtime/vmThread.hpp"
  57 #include "services/management.hpp"
  58 #include "services/memoryService.hpp"
  59 #include "services/memTracker.hpp"
  60 #include "utilities/events.hpp"
  61 #include "utilities/stack.inline.hpp"
  62 
  63 #include <math.h>
  64 
  65 // All sizes are in HeapWords.
  66 const size_t ParallelCompactData::Log2RegionSize  = 16; // 64K words


2099     // Let the size policy know we're done
2100     size_policy->major_collection_end(old_gen->used_in_bytes(), gc_cause);
2101 
2102     if (UseAdaptiveSizePolicy) {
2103       if (PrintAdaptiveSizePolicy) {
2104         gclog_or_tty->print("AdaptiveSizeStart: ");
2105         gclog_or_tty->stamp();
2106         gclog_or_tty->print_cr(" collection: %d ",
2107                        heap->total_collections());
2108         if (Verbose) {
2109           gclog_or_tty->print("old_gen_capacity: %d young_gen_capacity: %d",
2110             old_gen->capacity_in_bytes(), young_gen->capacity_in_bytes());
2111         }
2112       }
2113 
2114       // Don't check if the size_policy is ready here.  Let
2115       // the size_policy check that internally.
2116       if (UseAdaptiveGenerationSizePolicyAtMajorCollection &&
2117           ((gc_cause != GCCause::_java_lang_system_gc) ||
2118             UseAdaptiveSizePolicyWithSystemGC)) {
2119         // Swap the survivor spaces if from_space is empty
2120         if (UseAdaptiveSizePolicyResizeYoungGenAtMajorCollection &&
2121             young_gen->from_space()->is_empty()) {
2122           young_gen->from_space()->clear(SpaceDecorator::Mangle);
2123           young_gen->swap_spaces();
2124         }
2125 
2126         // Calculate optimal free space amounts
2127         assert(young_gen->max_size() >
2128           young_gen->from_space()->capacity_in_bytes() +
2129           young_gen->to_space()->capacity_in_bytes(),
2130           "Sizes of space in young gen are out-of-bounds");
2131 
2132         size_t young_live = young_gen->used_in_bytes();
2133         size_t eden_live = young_gen->eden_space()->used_in_bytes();
2134         size_t old_live = old_gen->used_in_bytes();
2135         size_t cur_eden = young_gen->eden_space()->capacity_in_bytes();
2136         size_t max_old_gen_size = old_gen->max_gen_size();
2137         size_t max_eden_size = young_gen->max_size() -
2138           young_gen->from_space()->capacity_in_bytes() -
2139           young_gen->to_space()->capacity_in_bytes();
2140 
2141         // Used for diagnostics
2142         size_policy->clear_generation_free_space_flags();
2143 
2144         size_policy->compute_generations_free_space(young_live,
2145                                                     eden_live,
2146                                                     old_live,
2147                                                     cur_eden,
2148                                                     max_old_gen_size,
2149                                                     max_eden_size,
2150                                                     true /* full gc*/);
2151 
2152         size_policy->check_gc_overhead_limit(young_live,
2153                                              eden_live,
2154                                              max_old_gen_size,
2155                                              max_eden_size,
2156                                              true /* full gc*/,
2157                                              gc_cause,
2158                                              heap->collector_policy());
2159 
2160         size_policy->decay_supplemental_growth(true /* full gc*/);
2161 
2162         heap->resize_old_gen(
2163           size_policy->calculated_old_free_size_in_bytes());
2164 
2165         if (UseAdaptiveSizePolicyResizeYoungGenAtMajorCollection) {
2166           heap->resize_young_gen(size_policy->calculated_eden_size_in_bytes(),
2167                                  size_policy->calculated_survivor_size_in_bytes());
2168         }


2169       }
2170       if (PrintAdaptiveSizePolicy) {
2171         gclog_or_tty->print_cr("AdaptiveSizeStop: collection: %d ",
2172                        heap->total_collections());
2173       }
2174     }
2175 
2176     if (UsePerfData) {
2177       PSGCAdaptivePolicyCounters* const counters = heap->gc_policy_counters();
2178       counters->update_counters();
2179       counters->update_old_capacity(old_gen->capacity_in_bytes());
2180       counters->update_young_capacity(young_gen->capacity_in_bytes());
2181     }
2182 
2183     heap->resize_all_tlabs();
2184 
2185     // Resize the metaspace capactiy after a collection
2186     MetaspaceGC::compute_new_size();
2187 
2188     if (TraceGen1Time) accumulated_time()->stop();