1.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp Fri Apr 09 13:08:34 2010 -0400 1.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp Tue Apr 13 13:52:10 2010 -0700 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * Copyright 2002-2010 Sun Microsystems, Inc. All Rights Reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -184,18 +184,19 @@ 1.11 set_change_young_gen_for_maj_pauses(0); 1.12 } 1.13 1.14 - 1.15 // If this is not a full GC, only test and modify the young generation. 1.16 1.17 -void PSAdaptiveSizePolicy::compute_generation_free_space(size_t young_live, 1.18 - size_t eden_live, 1.19 - size_t old_live, 1.20 - size_t perm_live, 1.21 - size_t cur_eden, 1.22 - size_t max_old_gen_size, 1.23 - size_t max_eden_size, 1.24 - bool is_full_gc, 1.25 - GCCause::Cause gc_cause) { 1.26 +void PSAdaptiveSizePolicy::compute_generation_free_space( 1.27 + size_t young_live, 1.28 + size_t eden_live, 1.29 + size_t old_live, 1.30 + size_t perm_live, 1.31 + size_t cur_eden, 1.32 + size_t max_old_gen_size, 1.33 + size_t max_eden_size, 1.34 + bool is_full_gc, 1.35 + GCCause::Cause gc_cause, 1.36 + CollectorPolicy* collector_policy) { 1.37 1.38 // Update statistics 1.39 // Time statistics are updated as we go, update footprint stats here 1.40 @@ -380,91 +381,16 @@ 1.41 // Is too much time being spent in GC? 1.42 // Is the heap trying to grow beyond it's limits? 1.43 1.44 - const size_t free_in_old_gen = (size_t)(max_old_gen_size - avg_old_live()->average()); 1.45 + const size_t free_in_old_gen = 1.46 + (size_t)(max_old_gen_size - avg_old_live()->average()); 1.47 if (desired_promo_size > free_in_old_gen && desired_eden_size > eden_limit) { 1.48 - 1.49 - // eden_limit is the upper limit on the size of eden based on 1.50 - // the maximum size of the young generation and the sizes 1.51 - // of the survivor space. 1.52 - // The question being asked is whether the gc costs are high 1.53 - // and the space being recovered by a collection is low. 1.54 - // free_in_young_gen is the free space in the young generation 1.55 - // after a collection and promo_live is the free space in the old 1.56 - // generation after a collection. 1.57 - // 1.58 - // Use the minimum of the current value of the live in the 1.59 - // young gen or the average of the live in the young gen. 1.60 - // If the current value drops quickly, that should be taken 1.61 - // into account (i.e., don't trigger if the amount of free 1.62 - // space has suddenly jumped up). If the current is much 1.63 - // higher than the average, use the average since it represents 1.64 - // the longer term behavor. 1.65 - const size_t live_in_eden = MIN2(eden_live, (size_t) avg_eden_live()->average()); 1.66 - const size_t free_in_eden = eden_limit > live_in_eden ? 1.67 - eden_limit - live_in_eden : 0; 1.68 - const size_t total_free_limit = free_in_old_gen + free_in_eden; 1.69 - const size_t total_mem = max_old_gen_size + max_eden_size; 1.70 - const double mem_free_limit = total_mem * (GCHeapFreeLimit/100.0); 1.71 - if (PrintAdaptiveSizePolicy && (Verbose || 1.72 - (total_free_limit < (size_t) mem_free_limit))) { 1.73 - gclog_or_tty->print_cr( 1.74 - "PSAdaptiveSizePolicy::compute_generation_free_space limits:" 1.75 - " promo_limit: " SIZE_FORMAT 1.76 - " eden_limit: " SIZE_FORMAT 1.77 - " total_free_limit: " SIZE_FORMAT 1.78 - " max_old_gen_size: " SIZE_FORMAT 1.79 - " max_eden_size: " SIZE_FORMAT 1.80 - " mem_free_limit: " SIZE_FORMAT, 1.81 - promo_limit, eden_limit, total_free_limit, 1.82 - max_old_gen_size, max_eden_size, 1.83 - (size_t) mem_free_limit); 1.84 - } 1.85 - 1.86 - if (is_full_gc) { 1.87 - if (gc_cost() > gc_cost_limit && 1.88 - total_free_limit < (size_t) mem_free_limit) { 1.89 - // Collections, on average, are taking too much time, and 1.90 - // gc_cost() > gc_cost_limit 1.91 - // we have too little space available after a full gc. 1.92 - // total_free_limit < mem_free_limit 1.93 - // where 1.94 - // total_free_limit is the free space available in 1.95 - // both generations 1.96 - // total_mem is the total space available for allocation 1.97 - // in both generations (survivor spaces are not included 1.98 - // just as they are not included in eden_limit). 1.99 - // mem_free_limit is a fraction of total_mem judged to be an 1.100 - // acceptable amount that is still unused. 1.101 - // The heap can ask for the value of this variable when deciding 1.102 - // whether to thrown an OutOfMemory error. 1.103 - // Note that the gc time limit test only works for the collections 1.104 - // of the young gen + tenured gen and not for collections of the 1.105 - // permanent gen. That is because the calculation of the space 1.106 - // freed by the collection is the free space in the young gen + 1.107 - // tenured gen. 1.108 - // Ignore explicit GC's. Ignoring explicit GC's at this level 1.109 - // is the equivalent of the GC did not happen as far as the 1.110 - // overhead calculation is concerted (i.e., the flag is not set 1.111 - // and the count is not affected). Also the average will not 1.112 - // have been updated unless UseAdaptiveSizePolicyWithSystemGC is on. 1.113 - if (!GCCause::is_user_requested_gc(gc_cause) && 1.114 - !GCCause::is_serviceability_requested_gc(gc_cause)) { 1.115 - inc_gc_time_limit_count(); 1.116 - if (UseGCOverheadLimit && 1.117 - (gc_time_limit_count() > AdaptiveSizePolicyGCTimeLimitThreshold)){ 1.118 - // All conditions have been met for throwing an out-of-memory 1.119 - _gc_time_limit_exceeded = true; 1.120 - // Avoid consecutive OOM due to the gc time limit by resetting 1.121 - // the counter. 1.122 - reset_gc_time_limit_count(); 1.123 - } 1.124 - _print_gc_time_limit_would_be_exceeded = true; 1.125 - } 1.126 - } else { 1.127 - // Did not exceed overhead limits 1.128 - reset_gc_time_limit_count(); 1.129 - } 1.130 - } 1.131 + check_gc_overhead_limit(young_live, 1.132 + eden_live, 1.133 + max_old_gen_size, 1.134 + max_eden_size, 1.135 + is_full_gc, 1.136 + gc_cause, 1.137 + collector_policy); 1.138 } 1.139 1.140