src/hotspot/share/gc/g1/g1HeterogeneousHeapPolicy.cpp
author tschatzl
Wed, 17 Jul 2019 16:33:19 +0200
changeset 55722 5ee183a90e65
parent 55510 3e31a8beaae4
child 59198 92c98aa0f801
permissions -rw-r--r--
8227084: Add timing information for merge heap root preparation Reviewed-by: sangheki, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
53116
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
     1
/*
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
     4
 *
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
     7
 * published by the Free Software Foundation.
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
     8
 *
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    13
 * accompanied this code).
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    14
 *
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    18
 *
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    21
 * questions.
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    22
 *
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    23
 */
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    24
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    25
#include "precompiled.hpp"
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    26
#include "gc/g1/g1CollectedHeap.hpp"
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    27
#include "gc/g1/g1HeterogeneousHeapPolicy.hpp"
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    28
#include "gc/g1/g1Policy.hpp"
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    29
#include "gc/g1/heterogeneousHeapRegionManager.hpp"
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    30
54678
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    31
G1HeterogeneousHeapPolicy::G1HeterogeneousHeapPolicy(STWGCTimer* gc_timer) :
93f09ca4a7f8 8198505: Remove CollectorPolicy and its subclasses
stefank
parents: 53116
diff changeset
    32
  G1Policy(gc_timer), _manager(NULL) {}
53116
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    33
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    34
// We call the super class init(), after which we provision young_list_target_length() regions in dram.
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    35
void G1HeterogeneousHeapPolicy::init(G1CollectedHeap* g1h, G1CollectionSet* collection_set) {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    36
  G1Policy::init(g1h, collection_set);
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    37
  _manager = HeterogeneousHeapRegionManager::manager();
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    38
  _manager->adjust_dram_regions((uint)young_list_target_length(), G1CollectedHeap::heap()->workers());
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    39
}
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    40
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    41
// After a collection pause, young list target length is updated. So we need to make sure we have enough regions in dram for young gen.
55510
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54678
diff changeset
    42
void G1HeterogeneousHeapPolicy::record_collection_pause_end(double pause_time_ms, size_t heap_used_bytes_before_gc) {
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54678
diff changeset
    43
  G1Policy::record_collection_pause_end(pause_time_ms, heap_used_bytes_before_gc);
53116
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    44
  _manager->adjust_dram_regions((uint)young_list_target_length(), G1CollectedHeap::heap()->workers());
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    45
}
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    46
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    47
// After a full collection, young list target length is updated. So we need to make sure we have enough regions in dram for young gen.
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    48
void G1HeterogeneousHeapPolicy::record_full_collection_end() {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    49
  G1Policy::record_full_collection_end();
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    50
  _manager->adjust_dram_regions((uint)young_list_target_length(), G1CollectedHeap::heap()->workers());
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    51
}
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    52
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    53
bool G1HeterogeneousHeapPolicy::force_upgrade_to_full() {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    54
  if (_manager->has_borrowed_regions()) {
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    55
    return true;
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    56
  }
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    57
  return false;
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff changeset
    58
}