< prev index next >

src/hotspot/share/gc/parallel/psAdaptiveSizePolicy.cpp

8221260: Initialize more class members on construction, remove some unused ones
Reviewed-by:

0 /*                                                                                                                         
1  * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.                                            
2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.                                                           
3  *                                                                                                                         
4  * This code is free software; you can redistribute it and/or modify it                                                    
5  * under the terms of the GNU General Public License version 2 only, as                                                    
6  * published by the Free Software Foundation.                                                                              
7  *                                                                                                                         
8  * This code is distributed in the hope that it will be useful, but WITHOUT                                                
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or                                                   
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License                                                   
11  * version 2 for more details (a copy is included in the LICENSE file that                                                 
12  * accompanied this code).                                                                                                 
13  *                                                                                                                         
14  * You should have received a copy of the GNU General Public License version                                               
15  * 2 along with this work; if not, write to the Free Software Foundation,                                                  
16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.                                                           
17  *                                                                                                                         
18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA                                                 
19  * or visit www.oracle.com if you need additional information or have any                                                  
20  * questions.                                                                                                              

0 /*
1  * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3  *
4  * This code is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 2 only, as
6  * published by the Free Software Foundation.
7  *
8  * This code is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
11  * version 2 for more details (a copy is included in the LICENSE file that
12  * accompanied this code).
13  *
14  * You should have received a copy of the GNU General Public License version
15  * 2 along with this work; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17  *
18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19  * or visit www.oracle.com if you need additional information or have any
20  * questions.

31 #include "gc/shared/gcUtil.inline.hpp"                                                                                     
32 #include "gc/shared/gcPolicyCounters.hpp"                                                                                  
33 #include "logging/log.hpp"                                                                                                 
34 #include "runtime/timer.hpp"                                                                                               
35 #include "utilities/align.hpp"                                                                                             
36 
37 #include <math.h>                                                                                                          
38 
39 PSAdaptiveSizePolicy::PSAdaptiveSizePolicy(size_t init_eden_size,                                                          
40                                            size_t init_promo_size,                                                         
41                                            size_t init_survivor_size,                                                      
42                                            size_t space_alignment,                                                         
43                                            double gc_pause_goal_sec,                                                       
44                                            double gc_minor_pause_goal_sec,                                                 
45                                            uint gc_cost_ratio) :                                                           
46      AdaptiveSizePolicy(init_eden_size,                                                                                    
47                         init_promo_size,                                                                                   
48                         init_survivor_size,                                                                                
49                         gc_pause_goal_sec,                                                                                 
50                         gc_cost_ratio),                                                                                    
                                                                                                                           
                                                                                                                           
                                                                                                                           
51      _collection_cost_margin_fraction(AdaptiveSizePolicyCollectionCostMargin / 100.0),                                     
                                                                                                                           
                                                                                                                           
52      _latest_major_mutator_interval_seconds(0),                                                                            
53      _space_alignment(space_alignment),                                                                                    
54      _gc_minor_pause_goal_sec(gc_minor_pause_goal_sec),                                                                    
55      _live_at_last_full_gc(init_promo_size),                                                                               
56      _young_gen_change_for_major_pause_count(0)                                                                            
                                                                                                                           
                                                                                                                           
                                                                                                                           
                                                                                                                           
                                                                                                                           
57 {                                                                                                                          
58   // Sizing policy statistics                                                                                              
59   _avg_major_pause    =                                                                                                    
60     new AdaptivePaddedAverage(AdaptiveTimeWeight, PausePadding);                                                           
61   _avg_minor_interval = new AdaptiveWeightedAverage(AdaptiveTimeWeight);                                                   
62   _avg_major_interval = new AdaptiveWeightedAverage(AdaptiveTimeWeight);                                                   
63                                                                                                                            
64   _avg_base_footprint = new AdaptiveWeightedAverage(AdaptiveSizePolicyWeight);                                             
65   _major_pause_old_estimator =                                                                                             
66     new LinearLeastSquareFit(AdaptiveSizePolicyWeight);                                                                    
67   _major_pause_young_estimator =                                                                                           
68     new LinearLeastSquareFit(AdaptiveSizePolicyWeight);                                                                    
69   _major_collection_estimator =                                                                                            
70     new LinearLeastSquareFit(AdaptiveSizePolicyWeight);                                                                    
71                                                                                                                            
72   _young_gen_size_increment_supplement = YoungGenerationSizeSupplement;                                                    
73   _old_gen_size_increment_supplement = TenuredGenerationSizeSupplement;                                                    
74                                                                                                                            
75   // Start the timers                                                                                                      
76   _major_timer.start();                                                                                                    
77                                                                                                                            
78   _old_gen_policy_is_ready = false;                                                                                        
79 }                                                                                                                          
80 
81 size_t PSAdaptiveSizePolicy::calculate_free_based_on_live(size_t live, uintx ratio_as_percentage) {                        
82   // We want to calculate how much free memory there can be based on the                                                   
83   // amount of live data currently in the old gen. Using the formula:                                                      
84   // ratio * (free + live) = free                                                                                          
85   // Some equation solving later we get:                                                                                   
86   // free = (live * ratio) / (1 - ratio)                                                                                   
87 
88   const double ratio = ratio_as_percentage / 100.0;                                                                        
89   const double ratio_inverse = 1.0 - ratio;                                                                                
90   const double tmp = live * ratio;                                                                                         
91   size_t free = (size_t)(tmp / ratio_inverse);                                                                             
92 
93   return free;                                                                                                             
94 }                                                                                                                          
95 
96 size_t PSAdaptiveSizePolicy::calculated_old_free_size_in_bytes() const {                                                   
97   size_t free_size = (size_t)(_promo_size + avg_promoted()->padded_average());                                             

31 #include "gc/shared/gcUtil.inline.hpp"
32 #include "gc/shared/gcPolicyCounters.hpp"
33 #include "logging/log.hpp"
34 #include "runtime/timer.hpp"
35 #include "utilities/align.hpp"
36 
37 #include <math.h>
38 
39 PSAdaptiveSizePolicy::PSAdaptiveSizePolicy(size_t init_eden_size,
40                                            size_t init_promo_size,
41                                            size_t init_survivor_size,
42                                            size_t space_alignment,
43                                            double gc_pause_goal_sec,
44                                            double gc_minor_pause_goal_sec,
45                                            uint gc_cost_ratio) :
46      AdaptiveSizePolicy(init_eden_size,
47                         init_promo_size,
48                         init_survivor_size,
49                         gc_pause_goal_sec,
50                         gc_cost_ratio),
51      _avg_major_pause(new AdaptivePaddedAverage(AdaptiveTimeWeight, PausePadding)),
52      _avg_base_footprint(new AdaptiveWeightedAverage(AdaptiveSizePolicyWeight)),
53      _gc_stats(),
54      _collection_cost_margin_fraction(AdaptiveSizePolicyCollectionCostMargin / 100.0),
55      _major_pause_old_estimator(new LinearLeastSquareFit(AdaptiveSizePolicyWeight)),
56      _major_pause_young_estimator(new LinearLeastSquareFit(AdaptiveSizePolicyWeight)),
57      _latest_major_mutator_interval_seconds(0),
58      _space_alignment(space_alignment),
59      _gc_minor_pause_goal_sec(gc_minor_pause_goal_sec),
60      _live_at_last_full_gc(init_promo_size),
61      _change_old_gen_for_min_pauses(0),
62      _change_young_gen_for_maj_pauses(0),
63      _old_gen_policy_is_ready(false),
64      _young_gen_size_increment_supplement(YoungGenerationSizeSupplement),
65      _old_gen_size_increment_supplement(TenuredGenerationSizeSupplement),
66      _bytes_absorbed_from_eden(0)
67 {

















68   // Start the timers
69   _major_timer.start();


70 }
71 
72 size_t PSAdaptiveSizePolicy::calculate_free_based_on_live(size_t live, uintx ratio_as_percentage) {
73   // We want to calculate how much free memory there can be based on the
74   // amount of live data currently in the old gen. Using the formula:
75   // ratio * (free + live) = free
76   // Some equation solving later we get:
77   // free = (live * ratio) / (1 - ratio)
78 
79   const double ratio = ratio_as_percentage / 100.0;
80   const double ratio_inverse = 1.0 - ratio;
81   const double tmp = live * ratio;
82   size_t free = (size_t)(tmp / ratio_inverse);
83 
84   return free;
85 }
86 
87 size_t PSAdaptiveSizePolicy::calculated_old_free_size_in_bytes() const {
88   size_t free_size = (size_t)(_promo_size + avg_promoted()->padded_average());
< prev index next >