hotspot/src/share/vm/gc/g1/survRateGroup.cpp
author ehelin
Mon, 19 Oct 2015 15:47:36 +0200
changeset 34131 d5fc001452bb
parent 33216 8ecefd0f0d10
child 35061 be6025ebffea
permissions -rw-r--r--
8139883: Add virtual destructor G1ParScanThreadState Reviewed-by: tschatzl, mgerdin, stefank
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     1
/*
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29796
diff changeset
     2
 * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     4
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     8
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    13
 * accompanied this code).
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    14
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5350
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5350
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5350
diff changeset
    21
 * questions.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    22
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    23
 */
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29796
diff changeset
    26
#include "gc/g1/g1CollectedHeap.inline.hpp"
33214
5a00fba36171 8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents: 30764
diff changeset
    27
#include "gc/g1/g1Predictions.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29796
diff changeset
    28
#include "gc/g1/heapRegion.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29796
diff changeset
    29
#include "gc/g1/survRateGroup.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "memory/allocation.hpp"
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    31
33214
5a00fba36171 8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents: 30764
diff changeset
    32
SurvRateGroup::SurvRateGroup(G1Predictions* predictor,
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    33
                             const char* name,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    34
                             size_t summary_surv_rates_len) :
33214
5a00fba36171 8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents: 30764
diff changeset
    35
    _predictor(predictor), _name(name),
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    36
    _summary_surv_rates_len(summary_surv_rates_len),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    37
    _summary_surv_rates_max_len(0),
2009
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
    38
    _summary_surv_rates(NULL),
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
    39
    _surv_rate(NULL),
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
    40
    _accum_surv_rate_pred(NULL),
12117
23b52cd6ca73 7152954: G1: Native memory leak during full GCs
brutisso
parents: 7397
diff changeset
    41
    _surv_rate_pred(NULL),
23b52cd6ca73 7152954: G1: Native memory leak during full GCs
brutisso
parents: 7397
diff changeset
    42
    _stats_arrays_length(0) {
2009
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
    43
  reset();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    44
  if (summary_surv_rates_len > 0) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    45
    size_t length = summary_surv_rates_len;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 12117
diff changeset
    46
      _summary_surv_rates = NEW_C_HEAP_ARRAY(NumberSeq*, length, mtGC);
12117
23b52cd6ca73 7152954: G1: Native memory leak during full GCs
brutisso
parents: 7397
diff changeset
    47
    for (size_t i = 0; i < length; ++i) {
23b52cd6ca73 7152954: G1: Native memory leak during full GCs
brutisso
parents: 7397
diff changeset
    48
      _summary_surv_rates[i] = new NumberSeq();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    49
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    50
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    51
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    52
  start_adding_regions();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    53
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    54
33214
5a00fba36171 8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents: 30764
diff changeset
    55
double SurvRateGroup::get_new_prediction(TruncatedSeq const* seq) const {
5a00fba36171 8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents: 30764
diff changeset
    56
  return _predictor->get_new_prediction(seq);
5a00fba36171 8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents: 30764
diff changeset
    57
}
5a00fba36171 8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents: 30764
diff changeset
    58
12117
23b52cd6ca73 7152954: G1: Native memory leak during full GCs
brutisso
parents: 7397
diff changeset
    59
void SurvRateGroup::reset() {
2009
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
    60
  _all_regions_allocated = 0;
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
    61
  _setup_seq_num         = 0;
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
    62
  _last_pred             = 0.0;
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
    63
  // the following will set up the arrays with length 1
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
    64
  _region_num            = 1;
12117
23b52cd6ca73 7152954: G1: Native memory leak during full GCs
brutisso
parents: 7397
diff changeset
    65
23b52cd6ca73 7152954: G1: Native memory leak during full GCs
brutisso
parents: 7397
diff changeset
    66
  // The call to stop_adding_regions() will use "new" to refill
23b52cd6ca73 7152954: G1: Native memory leak during full GCs
brutisso
parents: 7397
diff changeset
    67
  // the _surv_rate_pred array, so we need to make sure to call
23b52cd6ca73 7152954: G1: Native memory leak during full GCs
brutisso
parents: 7397
diff changeset
    68
  // "delete".
23b52cd6ca73 7152954: G1: Native memory leak during full GCs
brutisso
parents: 7397
diff changeset
    69
  for (size_t i = 0; i < _stats_arrays_length; ++i) {
23b52cd6ca73 7152954: G1: Native memory leak during full GCs
brutisso
parents: 7397
diff changeset
    70
    delete _surv_rate_pred[i];
23b52cd6ca73 7152954: G1: Native memory leak during full GCs
brutisso
parents: 7397
diff changeset
    71
  }
23b52cd6ca73 7152954: G1: Native memory leak during full GCs
brutisso
parents: 7397
diff changeset
    72
  _stats_arrays_length = 0;
23b52cd6ca73 7152954: G1: Native memory leak during full GCs
brutisso
parents: 7397
diff changeset
    73
2009
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
    74
  stop_adding_regions();
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
    75
  guarantee( _stats_arrays_length == 1, "invariant" );
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
    76
  guarantee( _surv_rate_pred[0] != NULL, "invariant" );
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
    77
  _surv_rate_pred[0]->add(0.4);
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
    78
  all_surviving_words_recorded(false);
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
    79
  _region_num = 0;
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
    80
}
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
    81
33215
dba714a14246 8139583: Fix formatting in survRateGroup.cpp
tschatzl
parents: 33214
diff changeset
    82
void SurvRateGroup::start_adding_regions() {
2009
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
    83
  _setup_seq_num   = _stats_arrays_length;
5350
cccf0925702e 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 2105
diff changeset
    84
  _region_num      = 0;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    85
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    86
33215
dba714a14246 8139583: Fix formatting in survRateGroup.cpp
tschatzl
parents: 33214
diff changeset
    87
void SurvRateGroup::stop_adding_regions() {
2009
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
    88
  if (_region_num > _stats_arrays_length) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    89
    double* old_surv_rate = _surv_rate;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    90
    double* old_accum_surv_rate_pred = _accum_surv_rate_pred;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    91
    TruncatedSeq** old_surv_rate_pred = _surv_rate_pred;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    92
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 12117
diff changeset
    93
    _surv_rate = NEW_C_HEAP_ARRAY(double, _region_num, mtGC);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 12117
diff changeset
    94
    _accum_surv_rate_pred = NEW_C_HEAP_ARRAY(double, _region_num, mtGC);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 12117
diff changeset
    95
    _surv_rate_pred = NEW_C_HEAP_ARRAY(TruncatedSeq*, _region_num, mtGC);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    96
12117
23b52cd6ca73 7152954: G1: Native memory leak during full GCs
brutisso
parents: 7397
diff changeset
    97
    for (size_t i = 0; i < _stats_arrays_length; ++i) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    98
      _surv_rate_pred[i] = old_surv_rate_pred[i];
12117
23b52cd6ca73 7152954: G1: Native memory leak during full GCs
brutisso
parents: 7397
diff changeset
    99
    }
2009
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
   100
    for (size_t i = _stats_arrays_length; i < _region_num; ++i) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   101
      _surv_rate_pred[i] = new TruncatedSeq(10);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   102
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   103
2009
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
   104
    _stats_arrays_length = _region_num;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   105
12117
23b52cd6ca73 7152954: G1: Native memory leak during full GCs
brutisso
parents: 7397
diff changeset
   106
    if (old_surv_rate != NULL) {
27880
afb974a04396 8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents: 24424
diff changeset
   107
      FREE_C_HEAP_ARRAY(double, old_surv_rate);
12117
23b52cd6ca73 7152954: G1: Native memory leak during full GCs
brutisso
parents: 7397
diff changeset
   108
    }
23b52cd6ca73 7152954: G1: Native memory leak during full GCs
brutisso
parents: 7397
diff changeset
   109
    if (old_accum_surv_rate_pred != NULL) {
27880
afb974a04396 8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents: 24424
diff changeset
   110
      FREE_C_HEAP_ARRAY(double, old_accum_surv_rate_pred);
12117
23b52cd6ca73 7152954: G1: Native memory leak during full GCs
brutisso
parents: 7397
diff changeset
   111
    }
23b52cd6ca73 7152954: G1: Native memory leak during full GCs
brutisso
parents: 7397
diff changeset
   112
    if (old_surv_rate_pred != NULL) {
27880
afb974a04396 8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents: 24424
diff changeset
   113
      FREE_C_HEAP_ARRAY(TruncatedSeq*, old_surv_rate_pred);
12117
23b52cd6ca73 7152954: G1: Native memory leak during full GCs
brutisso
parents: 7397
diff changeset
   114
    }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   115
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   116
12117
23b52cd6ca73 7152954: G1: Native memory leak during full GCs
brutisso
parents: 7397
diff changeset
   117
  for (size_t i = 0; i < _stats_arrays_length; ++i) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   118
    _surv_rate[i] = 0.0;
12117
23b52cd6ca73 7152954: G1: Native memory leak during full GCs
brutisso
parents: 7397
diff changeset
   119
  }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   120
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   121
33215
dba714a14246 8139583: Fix formatting in survRateGroup.cpp
tschatzl
parents: 33214
diff changeset
   122
int SurvRateGroup::next_age_index() {
2009
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
   123
  ++_region_num;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   124
  return (int) ++_all_regions_allocated;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   125
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   126
33215
dba714a14246 8139583: Fix formatting in survRateGroup.cpp
tschatzl
parents: 33214
diff changeset
   127
void SurvRateGroup::record_surviving_words(int age_in_group, size_t surv_words) {
2009
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
   128
  guarantee( 0 <= age_in_group && (size_t) age_in_group < _region_num,
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   129
             "pre-condition" );
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   130
  guarantee( _surv_rate[age_in_group] <= 0.00001,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   131
             "should only update each slot once" );
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   132
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   133
  double surv_rate = (double) surv_words / (double) HeapRegion::GrainWords;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   134
  _surv_rate[age_in_group] = surv_rate;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   135
  _surv_rate_pred[age_in_group]->add(surv_rate);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   136
  if ((size_t)age_in_group < _summary_surv_rates_len) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   137
    _summary_surv_rates[age_in_group]->add(surv_rate);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   138
    if ((size_t)(age_in_group+1) > _summary_surv_rates_max_len)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   139
      _summary_surv_rates_max_len = age_in_group+1;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   140
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   141
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   142
33216
8ecefd0f0d10 8138750: Remove dead code in survivor rate group
tschatzl
parents: 33215
diff changeset
   143
void SurvRateGroup::all_surviving_words_recorded(bool update_predictors) {
8ecefd0f0d10 8138750: Remove dead code in survivor rate group
tschatzl
parents: 33215
diff changeset
   144
  if (update_predictors && _region_num > 0) { // conservative
2009
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
   145
    double surv_rate = _surv_rate_pred[_region_num-1]->last();
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
   146
    for (size_t i = _region_num; i < _stats_arrays_length; ++i) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   147
      guarantee( _surv_rate[i] <= 0.00001,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   148
                 "the slot should not have been updated" );
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   149
      _surv_rate_pred[i]->add(surv_rate);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   150
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   151
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   152
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   153
  double accum = 0.0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   154
  double pred = 0.0;
2009
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
   155
  for (size_t i = 0; i < _stats_arrays_length; ++i) {
33214
5a00fba36171 8137082: Factor out G1 prediction code from G1CollectorPolicy and clean up
tschatzl
parents: 30764
diff changeset
   156
    pred = get_new_prediction(_surv_rate_pred[i]);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   157
    if (pred > 1.0) pred = 1.0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   158
    accum += pred;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   159
    _accum_surv_rate_pred[i] = accum;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   160
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   161
  _last_pred = pred;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   162
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   163
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   164
#ifndef PRODUCT
33215
dba714a14246 8139583: Fix formatting in survRateGroup.cpp
tschatzl
parents: 33214
diff changeset
   165
void SurvRateGroup::print() {
24092
e274d864545a 8039743: Use correct format specifier to print size_t values and pointers in the GC code
stefank
parents: 13195
diff changeset
   166
  gclog_or_tty->print_cr("Surv Rate Group: %s (" SIZE_FORMAT " entries)",
5350
cccf0925702e 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 2105
diff changeset
   167
                _name, _region_num);
2009
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
   168
  for (size_t i = 0; i < _region_num; ++i) {
24092
e274d864545a 8039743: Use correct format specifier to print size_t values and pointers in the GC code
stefank
parents: 13195
diff changeset
   169
    gclog_or_tty->print_cr("    age " SIZE_FORMAT_W(4) "   surv rate %6.2lf %%   pred %6.2lf %%",
33215
dba714a14246 8139583: Fix formatting in survRateGroup.cpp
tschatzl
parents: 33214
diff changeset
   170
                           i, _surv_rate[i] * 100.0,
dba714a14246 8139583: Fix formatting in survRateGroup.cpp
tschatzl
parents: 33214
diff changeset
   171
                           _predictor->get_new_prediction(_surv_rate_pred[i]) * 100.0);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   172
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   173
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   174
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   175
void
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   176
SurvRateGroup::print_surv_rate_summary() {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   177
  size_t length = _summary_surv_rates_max_len;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   178
  if (length == 0)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   179
    return;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   180
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24092
diff changeset
   181
  gclog_or_tty->cr();
24092
e274d864545a 8039743: Use correct format specifier to print size_t values and pointers in the GC code
stefank
parents: 13195
diff changeset
   182
  gclog_or_tty->print_cr("%s Rate Summary (for up to age " SIZE_FORMAT ")", _name, length-1);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   183
  gclog_or_tty->print_cr("      age range     survival rate (avg)      samples (avg)");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   184
  gclog_or_tty->print_cr("  ---------------------------------------------------------");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   185
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   186
  size_t index = 0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   187
  size_t limit = MIN2((int) length, 10);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   188
  while (index < limit) {
24092
e274d864545a 8039743: Use correct format specifier to print size_t values and pointers in the GC code
stefank
parents: 13195
diff changeset
   189
    gclog_or_tty->print_cr("           " SIZE_FORMAT_W(4)
33215
dba714a14246 8139583: Fix formatting in survRateGroup.cpp
tschatzl
parents: 33214
diff changeset
   190
                           "                 %6.2lf%%             %6.2lf",
dba714a14246 8139583: Fix formatting in survRateGroup.cpp
tschatzl
parents: 33214
diff changeset
   191
                           index, _summary_surv_rates[index]->avg() * 100.0,
dba714a14246 8139583: Fix formatting in survRateGroup.cpp
tschatzl
parents: 33214
diff changeset
   192
                           (double) _summary_surv_rates[index]->num());
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   193
    ++index;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   194
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   195
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   196
  gclog_or_tty->print_cr("  ---------------------------------------------------------");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   197
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   198
  int num = 0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   199
  double sum = 0.0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   200
  int samples = 0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   201
  while (index < length) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   202
    ++num;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   203
    sum += _summary_surv_rates[index]->avg() * 100.0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   204
    samples += _summary_surv_rates[index]->num();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   205
    ++index;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   206
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   207
    if (index == length || num % 10 == 0) {
24092
e274d864545a 8039743: Use correct format specifier to print size_t values and pointers in the GC code
stefank
parents: 13195
diff changeset
   208
      gclog_or_tty->print_cr("   " SIZE_FORMAT_W(4) " .. " SIZE_FORMAT_W(4)
33215
dba714a14246 8139583: Fix formatting in survRateGroup.cpp
tschatzl
parents: 33214
diff changeset
   209
                             "                 %6.2lf%%             %6.2lf",
dba714a14246 8139583: Fix formatting in survRateGroup.cpp
tschatzl
parents: 33214
diff changeset
   210
                             (index-1) / 10 * 10, index-1, sum / (double) num,
dba714a14246 8139583: Fix formatting in survRateGroup.cpp
tschatzl
parents: 33214
diff changeset
   211
                             (double) samples / (double) num);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   212
      sum = 0.0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   213
      num = 0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   214
      samples = 0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   215
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   216
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   217
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   218
  gclog_or_tty->print_cr("  ---------------------------------------------------------");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   219
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   220
#endif // PRODUCT