src/hotspot/share/gc/g1/g1YoungRemSetSamplingThread.cpp
author lkorinth
Mon, 17 Dec 2018 11:37:40 +0100
changeset 53034 de99beff5c0e
parent 52918 f94c7929a44b
child 53092 2a8dfb750d2c
permissions -rw-r--r--
8214946: G1: Initialize all class members on construction Reviewed-by: kbarrett, tschatzl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33608
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
     1
/*
53034
de99beff5c0e 8214946: G1: Initialize all class members on construction
lkorinth
parents: 52918
diff changeset
     2
 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
33608
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
     4
 *
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
     7
 * published by the Free Software Foundation.
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
     8
 *
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    13
 * accompanied this code).
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    14
 *
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    18
 *
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    21
 * questions.
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    22
 *
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    23
 */
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    24
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    25
#include "precompiled.hpp"
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    26
#include "gc/g1/g1CollectedHeap.inline.hpp"
37039
79f62b89a7a6 8151178: Move the collection set out of the G1 collector policy
mgerdin
parents: 36402
diff changeset
    27
#include "gc/g1/g1CollectionSet.hpp"
52918
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    28
#include "gc/g1/g1ConcurrentMark.inline.hpp"
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    29
#include "gc/g1/g1ConcurrentMarkThread.inline.hpp"
37985
539c597ee0fa 8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy
mgerdin
parents: 37081
diff changeset
    30
#include "gc/g1/g1Policy.hpp"
33608
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    31
#include "gc/g1/g1YoungRemSetSamplingThread.hpp"
36365
bcc9c9afda49 8150390: Move rs length sampling data to the sampling thread
mgerdin
parents: 35916
diff changeset
    32
#include "gc/g1/heapRegion.inline.hpp"
bcc9c9afda49 8150390: Move rs length sampling data to the sampling thread
mgerdin
parents: 35916
diff changeset
    33
#include "gc/g1/heapRegionRemSet.hpp"
47647
64dba69fc528 8189276: Make SuspendibleThreadSet and related code available to other GCs
rkennke
parents: 47216
diff changeset
    34
#include "gc/shared/suspendibleThreadSet.hpp"
33608
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    35
#include "runtime/mutexLocker.hpp"
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    36
36378
d63bca5c1439 8140600: Convert unnecessarily malloc'd Monitors to value members
drwhite
parents: 36365
diff changeset
    37
G1YoungRemSetSamplingThread::G1YoungRemSetSamplingThread() :
d63bca5c1439 8140600: Convert unnecessarily malloc'd Monitors to value members
drwhite
parents: 36365
diff changeset
    38
    ConcurrentGCThread(),
d63bca5c1439 8140600: Convert unnecessarily malloc'd Monitors to value members
drwhite
parents: 36365
diff changeset
    39
    _monitor(Mutex::nonleaf,
d63bca5c1439 8140600: Convert unnecessarily malloc'd Monitors to value members
drwhite
parents: 36365
diff changeset
    40
             "G1YoungRemSetSamplingThread monitor",
d63bca5c1439 8140600: Convert unnecessarily malloc'd Monitors to value members
drwhite
parents: 36365
diff changeset
    41
             true,
52918
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    42
             Monitor::_safepoint_check_never),
53034
de99beff5c0e 8214946: G1: Initialize all class members on construction
lkorinth
parents: 52918
diff changeset
    43
    _last_periodic_gc_attempt_s(os::elapsedTime()),
de99beff5c0e 8214946: G1: Initialize all class members on construction
lkorinth
parents: 52918
diff changeset
    44
    _vtime_accum(0) {
35916
23189249c2c1 8147884: Names of GC threads should be set before the threads start
asmotrak
parents: 33608
diff changeset
    45
  set_name("G1 Young RemSet Sampling");
33608
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    46
  create_and_start();
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    47
}
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    48
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    49
void G1YoungRemSetSamplingThread::sleep_before_next_cycle() {
36378
d63bca5c1439 8140600: Convert unnecessarily malloc'd Monitors to value members
drwhite
parents: 36365
diff changeset
    50
  MutexLockerEx x(&_monitor, Mutex::_no_safepoint_check_flag);
37081
7656f5356a5d 8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents: 37039
diff changeset
    51
  if (!should_terminate()) {
52918
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    52
    uintx waitms = G1ConcRefinementServiceIntervalMillis;
36378
d63bca5c1439 8140600: Convert unnecessarily malloc'd Monitors to value members
drwhite
parents: 36365
diff changeset
    53
    _monitor.wait(Mutex::_no_safepoint_check_flag, waitms);
33608
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    54
  }
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    55
}
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    56
52918
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    57
bool G1YoungRemSetSamplingThread::should_start_periodic_gc() {
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    58
  // If we are currently in a concurrent mark we are going to uncommit memory soon.
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    59
  if (G1CollectedHeap::heap()->concurrent_mark()->cm_thread()->during_cycle()) {
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    60
    log_debug(gc, periodic)("Concurrent cycle in progress. Skipping.");
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    61
    return false;
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    62
  }
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    63
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    64
  // Check if enough time has passed since the last GC.
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    65
  uintx time_since_last_gc;
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    66
  if ((G1PeriodicGCInterval == 0) ||
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    67
      ((time_since_last_gc = (uintx)Universe::heap()->millis_since_last_gc()) < G1PeriodicGCInterval)) {
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    68
    log_debug(gc, periodic)("Last GC occurred " UINTX_FORMAT "ms before which is below threshold " UINTX_FORMAT "ms. Skipping.",
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    69
                            time_since_last_gc, G1PeriodicGCInterval);
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    70
    return false;
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    71
  }
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    72
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    73
  // Check if load is lower than max.
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    74
  double recent_load;
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    75
  if ((G1PeriodicGCSystemLoadThreshold > 0) &&
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    76
      (os::loadavg(&recent_load, 1) == -1 || recent_load > G1PeriodicGCSystemLoadThreshold)) {
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    77
    log_debug(gc, periodic)("Load %1.2f is higher than threshold " UINTX_FORMAT ". Skipping.",
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    78
                            recent_load, G1PeriodicGCSystemLoadThreshold);
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    79
    return false;
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    80
  }
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    81
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    82
  return true;
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    83
}
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    84
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    85
void G1YoungRemSetSamplingThread::check_for_periodic_gc(){
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    86
  if ((os::elapsedTime() - _last_periodic_gc_attempt_s) > (G1PeriodicGCInterval / 1000.0)) {
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    87
    log_debug(gc, periodic)("Checking for periodic GC.");
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    88
    if (should_start_periodic_gc()) {
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    89
      Universe::heap()->collect(GCCause::_g1_periodic_collection);
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    90
    }
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    91
    _last_periodic_gc_attempt_s = os::elapsedTime();
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    92
  }
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    93
}
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
    94
33608
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    95
void G1YoungRemSetSamplingThread::run_service() {
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    96
  double vtime_start = os::elapsedVTime();
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    97
37081
7656f5356a5d 8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents: 37039
diff changeset
    98
  while (!should_terminate()) {
33608
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
    99
    sample_young_list_rs_lengths();
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
   100
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
   101
    if (os::supports_vtime()) {
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
   102
      _vtime_accum = (os::elapsedVTime() - vtime_start);
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
   103
    } else {
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
   104
      _vtime_accum = 0.0;
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
   105
    }
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
   106
52918
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
   107
    check_for_periodic_gc();
f94c7929a44b 8212657: Implementation of JDK-8204089 Promptly Return Unused Committed Memory from G1
tschatzl
parents: 48969
diff changeset
   108
33608
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
   109
    sleep_before_next_cycle();
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
   110
  }
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
   111
}
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
   112
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
   113
void G1YoungRemSetSamplingThread::stop_service() {
36378
d63bca5c1439 8140600: Convert unnecessarily malloc'd Monitors to value members
drwhite
parents: 36365
diff changeset
   114
  MutexLockerEx x(&_monitor, Mutex::_no_safepoint_check_flag);
d63bca5c1439 8140600: Convert unnecessarily malloc'd Monitors to value members
drwhite
parents: 36365
diff changeset
   115
  _monitor.notify();
33608
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
   116
}
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
   117
39698
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   118
class G1YoungRemSetSamplingClosure : public HeapRegionClosure {
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   119
  SuspendibleThreadSetJoiner* _sts;
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   120
  size_t _regions_visited;
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   121
  size_t _sampled_rs_lengths;
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   122
public:
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   123
  G1YoungRemSetSamplingClosure(SuspendibleThreadSetJoiner* sts) :
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   124
    HeapRegionClosure(), _sts(sts), _regions_visited(0), _sampled_rs_lengths(0) { }
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   125
48969
jwilhelm
parents: 48890
diff changeset
   126
  virtual bool do_heap_region(HeapRegion* r) {
39698
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   127
    size_t rs_length = r->rem_set()->occupied();
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   128
    _sampled_rs_lengths += rs_length;
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   129
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   130
    // Update the collection set policy information for this region
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   131
    G1CollectedHeap::heap()->collection_set()->update_young_region_prediction(r, rs_length);
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   132
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   133
    _regions_visited++;
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   134
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   135
    if (_regions_visited == 10) {
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   136
      if (_sts->should_yield()) {
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   137
        _sts->yield();
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   138
        // A gc may have occurred and our sampling data is stale and further
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   139
        // traversal of the collection set is unsafe
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   140
        return true;
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   141
      }
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   142
      _regions_visited = 0;
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   143
    }
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   144
    return false;
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   145
  }
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   146
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   147
  size_t sampled_rs_lengths() const { return _sampled_rs_lengths; }
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   148
};
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   149
33608
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
   150
void G1YoungRemSetSamplingThread::sample_young_list_rs_lengths() {
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
   151
  SuspendibleThreadSetJoiner sts;
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
   152
  G1CollectedHeap* g1h = G1CollectedHeap::heap();
37985
539c597ee0fa 8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy
mgerdin
parents: 37081
diff changeset
   153
  G1Policy* g1p = g1h->g1_policy();
39698
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   154
33608
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
   155
  if (g1p->adaptive_young_list_length()) {
39698
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   156
    G1YoungRemSetSamplingClosure cl(&sts);
33608
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
   157
39698
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   158
    G1CollectionSet* g1cs = g1h->collection_set();
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   159
    g1cs->iterate(&cl);
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   160
48969
jwilhelm
parents: 48890
diff changeset
   161
    if (cl.is_complete()) {
39698
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   162
      g1p->revise_young_list_target_length_if_necessary(cl.sampled_rs_lengths());
33608
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
   163
    }
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
   164
  }
7afc768e4d62 8138920: Refactor the sampling thread from ConcurrentG1RefineThread
drwhite
parents:
diff changeset
   165
}