hotspot/src/share/vm/gc/parallel/generationSizer.cpp
author tschatzl
Thu, 28 Jan 2016 13:30:12 +0100
changeset 35877 a2a62511d0f8
parent 30764 fec48bf5a827
child 37462 58bb9394a98b
permissions -rw-r--r--
8146987: Improve Parallel GC Full GC by caching results of live_words_in_range() Summary: A large part of time in the parallel scavenge collector is spent finding out the amount of live words within memory ranges to find out where to move an object to. Try to incrementally calculate this value. Reviewed-by: tschatzl, mgerdin, jmasa Contributed-by: ray alex <sky1young@gmail.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21561
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
     1
/*
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 28631
diff changeset
     2
 * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
21561
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
     4
 *
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
     8
 *
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    13
 * accompanied this code).
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    14
 *
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    18
 *
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    21
 * questions.
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    22
 *
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    23
 */
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    24
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    25
#include "precompiled.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 28631
diff changeset
    26
#include "gc/parallel/generationSizer.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 28631
diff changeset
    27
#include "gc/shared/collectorPolicy.hpp"
21561
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    28
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    29
void GenerationSizer::trace_gen_sizes(const char* const str) {
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    30
  if (TracePageSizes) {
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    31
    tty->print_cr("%s:  " SIZE_FORMAT "," SIZE_FORMAT " "
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    32
                  SIZE_FORMAT "," SIZE_FORMAT " "
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    33
                  SIZE_FORMAT,
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    34
                  str,
24941
4ebbe176a7b1 8042298: Remove the names gen0 and gen1 from the GC code
jwilhelm
parents: 24353
diff changeset
    35
                  _min_old_size / K, _max_old_size / K,
4ebbe176a7b1 8042298: Remove the names gen0 and gen1 from the GC code
jwilhelm
parents: 24353
diff changeset
    36
                  _min_young_size / K, _max_young_size / K,
21561
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    37
                  _max_heap_byte_size / K);
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    38
  }
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    39
}
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    40
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    41
void GenerationSizer::initialize_alignments() {
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    42
  _space_alignment = _gen_alignment = default_gen_alignment();
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    43
  _heap_alignment = compute_heap_alignment();
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    44
}
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    45
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    46
void GenerationSizer::initialize_flags() {
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    47
  // Do basic sizing work
24353
148147d21135 8027643: Merge GenCollectorPolicy and TwoGenerationCollectorPolicy
jwilhelm
parents: 21570
diff changeset
    48
  GenCollectorPolicy::initialize_flags();
21561
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    49
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    50
  // The survivor ratio's are calculated "raw", unlike the
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    51
  // default gc, which adds 2 to the ratio value. We need to
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    52
  // make sure the values are valid before using them.
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    53
  if (MinSurvivorRatio < 3) {
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    54
    FLAG_SET_ERGO(uintx, MinSurvivorRatio, 3);
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    55
  }
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    56
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    57
  if (InitialSurvivorRatio < 3) {
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    58
    FLAG_SET_ERGO(uintx, InitialSurvivorRatio, 3);
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    59
  }
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    60
}
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    61
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    62
void GenerationSizer::initialize_size_info() {
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    63
  trace_gen_sizes("ps heap raw");
28631
a56cae1b428d 8066875: VirtualSpace does not use large pages
ehelin
parents: 27251
diff changeset
    64
  const size_t max_page_sz = os::page_size_for_region_aligned(_max_heap_byte_size, 8);
26700
8107d0778244 8049864: TestParallelHeapSizeFlags fails with unexpected heap size
ehelin
parents: 25366
diff changeset
    65
  const size_t min_pages = 4; // 1 for eden + 1 for each survivor + 1 for old
28631
a56cae1b428d 8066875: VirtualSpace does not use large pages
ehelin
parents: 27251
diff changeset
    66
  const size_t min_page_sz = os::page_size_for_region_aligned(_min_heap_byte_size, min_pages);
26700
8107d0778244 8049864: TestParallelHeapSizeFlags fails with unexpected heap size
ehelin
parents: 25366
diff changeset
    67
  const size_t page_sz = MIN2(max_page_sz, min_page_sz);
21561
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    68
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    69
  // Can a page size be something else than a power of two?
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    70
  assert(is_power_of_2((intptr_t)page_sz), "must be a power of 2");
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    71
  size_t new_alignment = round_to(page_sz, _gen_alignment);
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    72
  if (new_alignment != _gen_alignment) {
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    73
    _gen_alignment = new_alignment;
21570
7006807e3cc8 8027960: Assertion assert(end >= start) failed during nightly testing on solaris
sjohanss
parents: 21561
diff changeset
    74
    _space_alignment = new_alignment;
21561
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    75
    // Redo everything from the start
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    76
    initialize_flags();
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    77
  }
24353
148147d21135 8027643: Merge GenCollectorPolicy and TwoGenerationCollectorPolicy
jwilhelm
parents: 21570
diff changeset
    78
  GenCollectorPolicy::initialize_size_info();
21561
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    79
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    80
  trace_gen_sizes("ps heap rnd");
c619b1cb4554 8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
diff changeset
    81
}