src/hotspot/share/gc/g1/g1CollectionSetChooser.hpp
author mgronlun
Wed, 30 Oct 2019 19:43:52 +0100
changeset 58863 c16ac7a2eba4
parent 53704 ef72c85a0534
permissions -rw-r--r--
8226511: Implement JFR Event Streaming Reviewed-by: egahlin, mseledtsov, mgronlun Contributed-by: erik.gahlin@oracle.com, mikhailo.seledtsov@oracle.com, markus.gronlund@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
53704
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
     1
/*
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
     2
 * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
     4
 *
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
     8
 *
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    14
 *
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    18
 *
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    21
 * questions.
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    22
 *
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    23
 */
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    24
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    25
#ifndef SHARE_GC_G1_G1COLLECTIONSETCHOOSER_HPP
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    26
#define SHARE_GC_G1_G1COLLECTIONSETCHOOSER_HPP
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    27
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    28
#include "gc/g1/heapRegion.hpp"
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    29
#include "memory/allocation.hpp"
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    30
#include "runtime/globals.hpp"
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    31
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    32
class G1CollectionSetCandidates;
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    33
class WorkGang;
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    34
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    35
// Helper class to calculate collection set candidates, and containing some related
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    36
// methods.
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    37
class G1CollectionSetChooser : public AllStatic {
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    38
  static uint calculate_work_chunk_size(uint num_workers, uint num_regions);
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    39
public:
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    40
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    41
  static size_t mixed_gc_live_threshold_bytes() {
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    42
    return HeapRegion::GrainBytes * (size_t) G1MixedGCLiveThresholdPercent / 100;
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    43
  }
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    44
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    45
  static bool region_occupancy_low_enough_for_evac(size_t live_bytes) {
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    46
    return live_bytes < mixed_gc_live_threshold_bytes();
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    47
  }
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    48
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    49
  // Determine whether to add the given region to the collection set candidates or
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    50
  // not. Currently, we skip pinned regions and regions whose live
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    51
  // bytes are over the threshold. Humongous regions may be reclaimed during cleanup.
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    52
  // Regions also need a complete remembered set to be a candidate.
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    53
  static bool should_add(HeapRegion* hr);
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    54
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    55
  // Build and return set of collection set candidates sorted by decreasing gc
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    56
  // efficiency.
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    57
  static G1CollectionSetCandidates* build(WorkGang* workers, uint max_num_regions);
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    58
};
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    59
ef72c85a0534 8217328: Rename CollectionSetChooser to G1CollectionSetChooser
tschatzl
parents:
diff changeset
    60
#endif // SHARE_GC_G1_G1COLLECTIONSETCHOOSER_HPP