src/share/vm/gc_implementation/shared/ageTable.cpp

Mon, 12 Aug 2019 18:30:40 +0300

author
apetushkov
date
Mon, 12 Aug 2019 18:30:40 +0300
changeset 9858
b985cbb00e68
parent 6680
78bbf4d43a14
child 9931
fd44df5e3bc3
permissions
-rw-r--r--

8223147: JFR Backport
8199712: Flight Recorder
8203346: JFR: Inconsistent signature of jfr_add_string_constant
8195817: JFR.stop should require name of recording
8195818: JFR.start should increase autogenerated name by one
8195819: Remove recording=x from jcmd JFR.check output
8203921: JFR thread sampling is missing fixes from JDK-8194552
8203929: Limit amount of data for JFR.dump
8203664: JFR start failure after AppCDS archive created with JFR StartFlightRecording
8003209: JFR events for network utilization
8207392: [PPC64] Implement JFR profiling
8202835: jfr/event/os/TestSystemProcess.java fails on missing events
Summary: Backport JFR from JDK11. Initial integration
Reviewed-by: neugens

duke@435 1 /*
drchase@6680 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "gc_implementation/shared/ageTable.hpp"
apetushkov@9858 27 #include "gc_implementation/shared/ageTableTracer.hpp"
stefank@2314 28 #include "gc_implementation/shared/gcPolicyCounters.hpp"
stefank@2314 29 #include "memory/collectorPolicy.hpp"
stefank@2314 30 #include "memory/resourceArea.hpp"
stefank@2314 31 #include "memory/sharedHeap.hpp"
stefank@2314 32 #include "utilities/copy.hpp"
stefank@2314 33
trims@1907 34 /* Copyright (c) 1992-2009 Oracle and/or its affiliates, and Stanford University.
duke@435 35 See the LICENSE file for license information. */
duke@435 36
duke@435 37 ageTable::ageTable(bool global) {
duke@435 38
duke@435 39 clear();
duke@435 40
duke@435 41 if (UsePerfData && global) {
duke@435 42
duke@435 43 ResourceMark rm;
duke@435 44 EXCEPTION_MARK;
duke@435 45
duke@435 46 const char* agetable_ns = "generation.0.agetable";
duke@435 47 const char* bytes_ns = PerfDataManager::name_space(agetable_ns, "bytes");
duke@435 48
duke@435 49 for(int age = 0; age < table_size; age ++) {
duke@435 50 char age_name[10];
duke@435 51 jio_snprintf(age_name, sizeof(age_name), "%2.2d", age);
duke@435 52 const char* cname = PerfDataManager::counter_name(bytes_ns, age_name);
duke@435 53 _perf_sizes[age] = PerfDataManager::create_variable(SUN_GC, cname,
duke@435 54 PerfData::U_Bytes,
duke@435 55 CHECK);
duke@435 56 }
duke@435 57
duke@435 58 const char* cname = PerfDataManager::counter_name(agetable_ns, "size");
duke@435 59 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_None,
duke@435 60 table_size, CHECK);
duke@435 61 }
duke@435 62 }
duke@435 63
duke@435 64 void ageTable::clear() {
duke@435 65 for (size_t* p = sizes; p < sizes + table_size; ++p) {
duke@435 66 *p = 0;
duke@435 67 }
duke@435 68 }
duke@435 69
duke@435 70 void ageTable::merge(ageTable* subTable) {
duke@435 71 for (int i = 0; i < table_size; i++) {
duke@435 72 sizes[i]+= subTable->sizes[i];
duke@435 73 }
duke@435 74 }
duke@435 75
apetrusenko@980 76 void ageTable::merge_par(ageTable* subTable) {
apetrusenko@980 77 for (int i = 0; i < table_size; i++) {
apetrusenko@980 78 Atomic::add_ptr(subTable->sizes[i], &sizes[i]);
apetrusenko@980 79 }
apetrusenko@980 80 }
apetrusenko@980 81
apetushkov@9858 82 uint ageTable::compute_tenuring_threshold(size_t survivor_capacity, GCTracer &tracer) {
duke@435 83 size_t desired_survivor_size = (size_t)((((double) survivor_capacity)*TargetSurvivorRatio)/100);
duke@435 84 size_t total = 0;
jwilhelm@4129 85 uint age = 1;
duke@435 86 assert(sizes[0] == 0, "no objects with age zero should be recorded");
duke@435 87 while (age < table_size) {
duke@435 88 total += sizes[age];
duke@435 89 // check if including objects of age 'age' made us pass the desired
duke@435 90 // size, if so 'age' is the new threshold
duke@435 91 if (total > desired_survivor_size) break;
duke@435 92 age++;
duke@435 93 }
jwilhelm@4129 94 uint result = age < MaxTenuringThreshold ? age : MaxTenuringThreshold;
duke@435 95
apetushkov@9858 96 if (PrintTenuringDistribution || UsePerfData || AgeTableTracer::is_tenuring_distribution_event_enabled()) {
duke@435 97
duke@435 98 if (PrintTenuringDistribution) {
duke@435 99 gclog_or_tty->cr();
hseigel@4465 100 gclog_or_tty->print_cr("Desired survivor size " SIZE_FORMAT " bytes, new threshold %u (max %u)",
drchase@6680 101 desired_survivor_size*oopSize, result, (int) MaxTenuringThreshold);
duke@435 102 }
duke@435 103
duke@435 104 total = 0;
duke@435 105 age = 1;
duke@435 106 while (age < table_size) {
duke@435 107 total += sizes[age];
duke@435 108 if (sizes[age] > 0) {
duke@435 109 if (PrintTenuringDistribution) {
drchase@6680 110 gclog_or_tty->print_cr("- age %3u: " SIZE_FORMAT_W(10) " bytes, " SIZE_FORMAT_W(10) " total",
drchase@6680 111 age, sizes[age]*oopSize, total*oopSize);
duke@435 112 }
duke@435 113 }
apetushkov@9858 114 AgeTableTracer::send_tenuring_distribution_event(age, wordSize * oopSize, tracer);
duke@435 115 if (UsePerfData) {
duke@435 116 _perf_sizes[age]->set_value(sizes[age]*oopSize);
duke@435 117 }
duke@435 118 age++;
duke@435 119 }
duke@435 120 if (UsePerfData) {
duke@435 121 SharedHeap* sh = SharedHeap::heap();
duke@435 122 CollectorPolicy* policy = sh->collector_policy();
duke@435 123 GCPolicyCounters* gc_counters = policy->counters();
duke@435 124 gc_counters->tenuring_threshold()->set_value(result);
duke@435 125 gc_counters->desired_survivor_size()->set_value(
duke@435 126 desired_survivor_size*oopSize);
duke@435 127 }
duke@435 128 }
duke@435 129
duke@435 130 return result;
duke@435 131 }

mercurial