63 void ageTable::clear() { 64 for (size_t* p = sizes; p < sizes + table_size; ++p) { 65 *p = 0; 66 } 67 } 68 69 void ageTable::merge(ageTable* subTable) { 70 for (int i = 0; i < table_size; i++) { 71 sizes[i]+= subTable->sizes[i]; 72 } 73 } 74 75 void ageTable::merge_par(ageTable* subTable) { 76 for (int i = 0; i < table_size; i++) { 77 Atomic::add_ptr(subTable->sizes[i], &sizes[i]); 78 } 79 } 80 81 uint ageTable::compute_tenuring_threshold(size_t survivor_capacity) { 82 size_t desired_survivor_size = (size_t)((((double) survivor_capacity)*TargetSurvivorRatio)/100); 83 size_t total = 0; 84 uint age = 1; 85 assert(sizes[0] == 0, "no objects with age zero should be recorded"); 86 while (age < table_size) { 87 total += sizes[age]; 88 // check if including objects of age 'age' made us pass the desired 89 // size, if so 'age' is the new threshold 90 if (total > desired_survivor_size) break; 91 age++; 92 } 93 uint result = age < MaxTenuringThreshold ? age : MaxTenuringThreshold; 94 95 if (PrintTenuringDistribution || UsePerfData) { 96 97 if (PrintTenuringDistribution) { 98 gclog_or_tty->cr(); 99 gclog_or_tty->print_cr("Desired survivor size " SIZE_FORMAT " bytes, new threshold %u (max %u)", 100 desired_survivor_size*oopSize, result, MaxTenuringThreshold); 101 } 102 103 total = 0; 104 age = 1; 105 while (age < table_size) { 106 total += sizes[age]; 107 if (sizes[age] > 0) { 108 if (PrintTenuringDistribution) { 109 gclog_or_tty->print_cr("- age %3u: %10ld bytes, %10ld total", 110 age, sizes[age]*oopSize, total*oopSize); 111 } 112 } 113 if (UsePerfData) { 114 _perf_sizes[age]->set_value(sizes[age]*oopSize); 115 } 116 age++; 117 } 118 if (UsePerfData) { 119 SharedHeap* sh = SharedHeap::heap(); 120 CollectorPolicy* policy = sh->collector_policy(); 121 GCPolicyCounters* gc_counters = policy->counters(); 122 gc_counters->tenuring_threshold()->set_value(result); 123 gc_counters->desired_survivor_size()->set_value( 124 desired_survivor_size*oopSize); | 63 void ageTable::clear() { 64 for (size_t* p = sizes; p < sizes + table_size; ++p) { 65 *p = 0; 66 } 67 } 68 69 void ageTable::merge(ageTable* subTable) { 70 for (int i = 0; i < table_size; i++) { 71 sizes[i]+= subTable->sizes[i]; 72 } 73 } 74 75 void ageTable::merge_par(ageTable* subTable) { 76 for (int i = 0; i < table_size; i++) { 77 Atomic::add_ptr(subTable->sizes[i], &sizes[i]); 78 } 79 } 80 81 uint ageTable::compute_tenuring_threshold(size_t survivor_capacity) { 82 size_t desired_survivor_size = (size_t)((((double) survivor_capacity)*TargetSurvivorRatio)/100); 83 uint result; 84 85 if (AlwaysTenure || NeverTenure) { 86 assert(MaxTenuringThreshold == 0 || MaxTenuringThreshold == markOopDesc::max_age + 1, 87 err_msg("MaxTenuringThreshold should be 0 or markOopDesc::max_age + 1, but is ", MaxTenuringThreshold)); 88 result = MaxTenuringThreshold; 89 } else { 90 size_t total = 0; 91 uint age = 1; 92 assert(sizes[0] == 0, "no objects with age zero should be recorded"); 93 while (age < table_size) { 94 total += sizes[age]; 95 // check if including objects of age 'age' made us pass the desired 96 // size, if so 'age' is the new threshold 97 if (total > desired_survivor_size) break; 98 age++; 99 } 100 result = age < MaxTenuringThreshold ? age : MaxTenuringThreshold; 101 } 102 103 if (PrintTenuringDistribution || UsePerfData) { 104 105 if (PrintTenuringDistribution) { 106 gclog_or_tty->cr(); 107 gclog_or_tty->print_cr("Desired survivor size " SIZE_FORMAT " bytes, new threshold " 108 UINTX_FORMAT " (max threshold " UINTX_FORMAT ")", 109 desired_survivor_size*oopSize, result, MaxTenuringThreshold); 110 } 111 112 size_t total = 0; 113 uint age = 1; 114 while (age < table_size) { 115 total += sizes[age]; 116 if (sizes[age] > 0) { 117 if (PrintTenuringDistribution) { 118 gclog_or_tty->print_cr("- age %3u: %10ld bytes, %10ld total", 119 age, sizes[age]*oopSize, total*oopSize); 120 } 121 } 122 if (UsePerfData) { 123 _perf_sizes[age]->set_value(sizes[age]*oopSize); 124 } 125 age++; 126 } 127 if (UsePerfData) { 128 SharedHeap* sh = SharedHeap::heap(); 129 CollectorPolicy* policy = sh->collector_policy(); 130 GCPolicyCounters* gc_counters = policy->counters(); 131 gc_counters->tenuring_threshold()->set_value(result); 132 gc_counters->desired_survivor_size()->set_value( 133 desired_survivor_size*oopSize); |