58 }
59
60 const char* cname = PerfDataManager::counter_name(agetable_ns, "size");
61 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_None,
62 table_size, CHECK);
63 }
64 }
65
66 void AgeTable::clear() {
67 for (size_t* p = sizes; p < sizes + table_size; ++p) {
68 *p = 0;
69 }
70 }
71
72 void AgeTable::merge(AgeTable* subTable) {
73 for (int i = 0; i < table_size; i++) {
74 sizes[i]+= subTable->sizes[i];
75 }
76 }
77
78 uint AgeTable::compute_tenuring_threshold(size_t survivor_capacity, GCPolicyCounters* gc_counters) {
79 size_t desired_survivor_size = (size_t)((((double) survivor_capacity)*TargetSurvivorRatio)/100);
80 uint result;
81
82 if (AlwaysTenure || NeverTenure) {
83 assert(MaxTenuringThreshold == 0 || MaxTenuringThreshold == markOopDesc::max_age + 1,
84 "MaxTenuringThreshold should be 0 or markOopDesc::max_age + 1, but is " UINTX_FORMAT, MaxTenuringThreshold);
85 result = MaxTenuringThreshold;
86 } else {
87 size_t total = 0;
88 uint age = 1;
89 assert(sizes[0] == 0, "no objects with age zero should be recorded");
90 while (age < table_size) {
91 total += sizes[age];
92 // check if including objects of age 'age' made us pass the desired
93 // size, if so 'age' is the new threshold
94 if (total > desired_survivor_size) break;
95 age++;
96 }
97 result = age < MaxTenuringThreshold ? age : MaxTenuringThreshold;
98 }
99
100
101 log_debug(gc, age)("Desired survivor size " SIZE_FORMAT " bytes, new threshold " UINTX_FORMAT " (max threshold " UINTX_FORMAT ")",
102 desired_survivor_size*oopSize, (uintx) result, MaxTenuringThreshold);
103
104 if (log_is_enabled(Trace, gc, age) || UsePerfData || AgeTableTracer::is_tenuring_distribution_event_enabled()) {
105 size_t total = 0;
106 uint age = 1;
107 while (age < table_size) {
108 size_t wordSize = sizes[age];
109 total += wordSize;
110 if (wordSize > 0) {
111 log_trace(gc, age)("- age %3u: " SIZE_FORMAT_W(10) " bytes, " SIZE_FORMAT_W(10) " total",
112 age, wordSize*oopSize, total*oopSize);
113 }
114 AgeTableTracer::send_tenuring_distribution_event(age, wordSize*oopSize);
115 if (UsePerfData) {
116 _perf_sizes[age]->set_value(wordSize*oopSize);
117 }
118 age++;
119 }
120 if (UsePerfData) {
121 gc_counters->tenuring_threshold()->set_value(result);
122 gc_counters->desired_survivor_size()->set_value(
123 desired_survivor_size*oopSize);
124 }
125 }
126
127 return result;
128 }
|
58 }
59
60 const char* cname = PerfDataManager::counter_name(agetable_ns, "size");
61 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_None,
62 table_size, CHECK);
63 }
64 }
65
66 void AgeTable::clear() {
67 for (size_t* p = sizes; p < sizes + table_size; ++p) {
68 *p = 0;
69 }
70 }
71
72 void AgeTable::merge(AgeTable* subTable) {
73 for (int i = 0; i < table_size; i++) {
74 sizes[i]+= subTable->sizes[i];
75 }
76 }
77
78 uint AgeTable::compute_tenuring_threshold(size_t desired_survivor_size) {
79 uint result;
80
81 if (AlwaysTenure || NeverTenure) {
82 assert(MaxTenuringThreshold == 0 || MaxTenuringThreshold == markOopDesc::max_age + 1,
83 "MaxTenuringThreshold should be 0 or markOopDesc::max_age + 1, but is " UINTX_FORMAT, MaxTenuringThreshold);
84 result = MaxTenuringThreshold;
85 } else {
86 size_t total = 0;
87 uint age = 1;
88 assert(sizes[0] == 0, "no objects with age zero should be recorded");
89 while (age < table_size) {
90 total += sizes[age];
91 // check if including objects of age 'age' made us pass the desired
92 // size, if so 'age' is the new threshold
93 if (total > desired_survivor_size) break;
94 age++;
95 }
96 result = age < MaxTenuringThreshold ? age : MaxTenuringThreshold;
97 }
98
99
100 log_debug(gc, age)("Desired survivor size " SIZE_FORMAT " bytes, new threshold " UINTX_FORMAT " (max threshold " UINTX_FORMAT ")",
101 desired_survivor_size * oopSize, (uintx) result, MaxTenuringThreshold);
102
103 return result;
104 }
105
106 void AgeTable::print_age_table(uint tenuring_threshold) {
107 if (log_is_enabled(Trace, gc, age) || UsePerfData || AgeTableTracer::is_tenuring_distribution_event_enabled()) {
108 log_trace(gc, age)("Age table with threshold %u (max threshold " UINTX_FORMAT ")",
109 tenuring_threshold, MaxTenuringThreshold);
110
111 size_t total = 0;
112 uint age = 1;
113 while (age < table_size) {
114 size_t wordSize = sizes[age];
115 total += wordSize;
116 if (wordSize > 0) {
117 log_trace(gc, age)("- age %3u: " SIZE_FORMAT_W(10) " bytes, " SIZE_FORMAT_W(10) " total",
118 age, wordSize * oopSize, total * oopSize);
119 }
120 AgeTableTracer::send_tenuring_distribution_event(age, wordSize * oopSize);
121 if (UsePerfData) {
122 _perf_sizes[age]->set_value(wordSize * oopSize);
123 }
124 age++;
125 }
126 }
127 }
|