author | tschatzl |
Mon, 24 Aug 2015 16:32:50 +0200 | |
changeset 32390 | b0f6868d46ee |
parent 32379 | aa14adafaf0f |
child 32602 | 27d046027824 |
permissions | -rw-r--r-- |
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
1 |
/* |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
4 |
* |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
8 |
* |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
13 |
* accompanied this code). |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
14 |
* |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
18 |
* |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
21 |
* questions. |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
22 |
* |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
23 |
*/ |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
24 |
|
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
26 |
#include "gc/g1/g1EvacStats.hpp" |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
27 |
#include "gc/shared/gcId.hpp" |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
28 |
#include "trace/tracing.hpp" |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
29 |
|
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
30 |
void G1EvacStats::adjust_desired_plab_sz() { |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
31 |
if (PrintPLAB) { |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
32 |
gclog_or_tty->print(" (allocated = " SIZE_FORMAT " wasted = " SIZE_FORMAT " " |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
33 |
"unused = " SIZE_FORMAT " used = " SIZE_FORMAT " " |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
34 |
"undo_waste = " SIZE_FORMAT " region_end_waste = " SIZE_FORMAT " " |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
35 |
"regions filled = %u direct_allocated = " SIZE_FORMAT " " |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
36 |
"failure_used = " SIZE_FORMAT " failure_waste = " SIZE_FORMAT ") ", |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
37 |
_allocated, _wasted, _unused, used(), _undo_wasted, _region_end_waste, |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
38 |
_regions_filled, _direct_allocated, _failure_used, _failure_waste); |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
39 |
} |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
40 |
|
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
41 |
if (ResizePLAB) { |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
42 |
|
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
43 |
assert(is_object_aligned(max_size()) && min_size() <= max_size(), |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
44 |
"PLAB clipping computation may be incorrect"); |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
45 |
|
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
46 |
if (_allocated == 0) { |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
47 |
assert((_unused == 0), |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
48 |
err_msg("Inconsistency in PLAB stats: " |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
49 |
"_allocated: "SIZE_FORMAT", " |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
50 |
"_wasted: "SIZE_FORMAT", " |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
51 |
"_region_end_waste: "SIZE_FORMAT", " |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
52 |
"_unused: "SIZE_FORMAT", " |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
53 |
"_used : "SIZE_FORMAT, |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
54 |
_allocated, _wasted, _region_end_waste, _unused, used())); |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
55 |
_allocated = 1; |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
56 |
} |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
57 |
// We account region end waste fully to PLAB allocation. This is not completely fair, |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
58 |
// but is a conservative assumption because PLABs may be sized flexibly while we |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
59 |
// cannot adjust direct allocations. |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
60 |
// In some cases, wasted_frac may become > 1 but that just reflects the problem |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
61 |
// with region_end_waste. |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
62 |
double wasted_frac = (double)(_unused + _wasted + _region_end_waste) / (double)_allocated; |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
63 |
size_t target_refills = (size_t)((wasted_frac * TargetSurvivorRatio) / TargetPLABWastePct); |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
64 |
if (target_refills == 0) { |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
65 |
target_refills = 1; |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
66 |
} |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
67 |
size_t cur_plab_sz = used() / target_refills; |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
68 |
// Take historical weighted average |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
69 |
_filter.sample(cur_plab_sz); |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
70 |
// Clip from above and below, and align to object boundary |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
71 |
size_t plab_sz; |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
72 |
plab_sz = MAX2(min_size(), (size_t)_filter.average()); |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
73 |
plab_sz = MIN2(max_size(), plab_sz); |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
74 |
plab_sz = align_object_size(plab_sz); |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
75 |
// Latch the result |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
76 |
_desired_net_plab_sz = plab_sz; |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
77 |
if (PrintPLAB) { |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
78 |
gclog_or_tty->print_cr(" (plab_sz = " SIZE_FORMAT " desired_plab_sz = " SIZE_FORMAT ") ", cur_plab_sz, plab_sz); |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
79 |
} |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
80 |
} |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
81 |
// Clear accumulators for next round. |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
82 |
reset(); |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
83 |
} |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
diff
changeset
|
84 |