1099 // as needed. |
1099 // as needed. |
1100 if (UseParNewGC) { |
1100 if (UseParNewGC) { |
1101 set_parnew_gc_flags(); |
1101 set_parnew_gc_flags(); |
1102 } |
1102 } |
1103 |
1103 |
|
1104 // MaxHeapSize is aligned down in collectorPolicy |
|
1105 size_t max_heap = align_size_down(MaxHeapSize, |
|
1106 CardTableRS::ct_max_alignment_constraint()); |
|
1107 |
1104 // Now make adjustments for CMS |
1108 // Now make adjustments for CMS |
1105 size_t young_gen_per_worker; |
1109 intx tenuring_default = (intx)6; |
1106 intx new_ratio; |
1110 size_t young_gen_per_worker = CMSYoungGenPerWorker; |
1107 size_t min_new_default; |
1111 |
1108 intx tenuring_default; |
1112 // Preferred young gen size for "short" pauses: |
1109 if (CMSUseOldDefaults) { // old defaults: "old" as of 6.0 |
1113 // upper bound depends on # of threads and NewRatio. |
1110 if FLAG_IS_DEFAULT(CMSYoungGenPerWorker) { |
|
1111 FLAG_SET_ERGO(intx, CMSYoungGenPerWorker, 4*M); |
|
1112 } |
|
1113 young_gen_per_worker = 4*M; |
|
1114 new_ratio = (intx)15; |
|
1115 min_new_default = 4*M; |
|
1116 tenuring_default = (intx)0; |
|
1117 } else { // new defaults: "new" as of 6.0 |
|
1118 young_gen_per_worker = CMSYoungGenPerWorker; |
|
1119 new_ratio = (intx)7; |
|
1120 min_new_default = 16*M; |
|
1121 tenuring_default = (intx)4; |
|
1122 } |
|
1123 |
|
1124 // Preferred young gen size for "short" pauses |
|
1125 const uintx parallel_gc_threads = |
1114 const uintx parallel_gc_threads = |
1126 (ParallelGCThreads == 0 ? 1 : ParallelGCThreads); |
1115 (ParallelGCThreads == 0 ? 1 : ParallelGCThreads); |
1127 const size_t preferred_max_new_size_unaligned = |
1116 const size_t preferred_max_new_size_unaligned = |
1128 ScaleForWordSize(young_gen_per_worker * parallel_gc_threads); |
1117 MIN2(max_heap/(NewRatio+1), ScaleForWordSize(young_gen_per_worker * parallel_gc_threads)); |
1129 const size_t preferred_max_new_size = |
1118 size_t preferred_max_new_size = |
1130 align_size_up(preferred_max_new_size_unaligned, os::vm_page_size()); |
1119 align_size_up(preferred_max_new_size_unaligned, os::vm_page_size()); |
1131 |
1120 |
1132 // Unless explicitly requested otherwise, size young gen |
1121 // Unless explicitly requested otherwise, size young gen |
1133 // for "short" pauses ~ 4M*ParallelGCThreads |
1122 // for "short" pauses ~ CMSYoungGenPerWorker*ParallelGCThreads |
1134 |
1123 |
1135 // If either MaxNewSize or NewRatio is set on the command line, |
1124 // If either MaxNewSize or NewRatio is set on the command line, |
1136 // assume the user is trying to set the size of the young gen. |
1125 // assume the user is trying to set the size of the young gen. |
1137 |
|
1138 if (FLAG_IS_DEFAULT(MaxNewSize) && FLAG_IS_DEFAULT(NewRatio)) { |
1126 if (FLAG_IS_DEFAULT(MaxNewSize) && FLAG_IS_DEFAULT(NewRatio)) { |
1139 |
1127 |
1140 // Set MaxNewSize to our calculated preferred_max_new_size unless |
1128 // Set MaxNewSize to our calculated preferred_max_new_size unless |
1141 // NewSize was set on the command line and it is larger than |
1129 // NewSize was set on the command line and it is larger than |
1142 // preferred_max_new_size. |
1130 // preferred_max_new_size. |
1145 } else { |
1133 } else { |
1146 FLAG_SET_ERGO(uintx, MaxNewSize, preferred_max_new_size); |
1134 FLAG_SET_ERGO(uintx, MaxNewSize, preferred_max_new_size); |
1147 } |
1135 } |
1148 if (PrintGCDetails && Verbose) { |
1136 if (PrintGCDetails && Verbose) { |
1149 // Too early to use gclog_or_tty |
1137 // Too early to use gclog_or_tty |
1150 tty->print_cr("Ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize); |
1138 tty->print_cr("CMS ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize); |
1151 } |
1139 } |
1152 |
|
1153 // Unless explicitly requested otherwise, prefer a large |
|
1154 // Old to Young gen size so as to shift the collection load |
|
1155 // to the old generation concurrent collector |
|
1156 |
|
1157 // If this is only guarded by FLAG_IS_DEFAULT(NewRatio) |
|
1158 // then NewSize and OldSize may be calculated. That would |
|
1159 // generally lead to some differences with ParNewGC for which |
|
1160 // there was no obvious reason. Also limit to the case where |
|
1161 // MaxNewSize has not been set. |
|
1162 |
|
1163 FLAG_SET_ERGO(intx, NewRatio, MAX2(NewRatio, new_ratio)); |
|
1164 |
1140 |
1165 // Code along this path potentially sets NewSize and OldSize |
1141 // Code along this path potentially sets NewSize and OldSize |
1166 |
1142 |
1167 // Calculate the desired minimum size of the young gen but if |
1143 assert(max_heap >= InitialHeapSize, "Error"); |
1168 // NewSize has been set on the command line, use it here since |
1144 assert(max_heap >= NewSize, "Error"); |
1169 // it should be the final value. |
|
1170 size_t min_new; |
|
1171 if (FLAG_IS_DEFAULT(NewSize)) { |
|
1172 min_new = align_size_up(ScaleForWordSize(min_new_default), |
|
1173 os::vm_page_size()); |
|
1174 } else { |
|
1175 min_new = NewSize; |
|
1176 } |
|
1177 size_t prev_initial_size = InitialHeapSize; |
|
1178 if (prev_initial_size != 0 && prev_initial_size < min_new + OldSize) { |
|
1179 FLAG_SET_ERGO(uintx, InitialHeapSize, min_new + OldSize); |
|
1180 // Currently minimum size and the initial heap sizes are the same. |
|
1181 set_min_heap_size(InitialHeapSize); |
|
1182 if (PrintGCDetails && Verbose) { |
|
1183 warning("Initial heap size increased to " SIZE_FORMAT " M from " |
|
1184 SIZE_FORMAT " M; use -XX:NewSize=... for finer control.", |
|
1185 InitialHeapSize/M, prev_initial_size/M); |
|
1186 } |
|
1187 } |
|
1188 |
|
1189 // MaxHeapSize is aligned down in collectorPolicy |
|
1190 size_t max_heap = |
|
1191 align_size_down(MaxHeapSize, |
|
1192 CardTableRS::ct_max_alignment_constraint()); |
|
1193 |
1145 |
1194 if (PrintGCDetails && Verbose) { |
1146 if (PrintGCDetails && Verbose) { |
1195 // Too early to use gclog_or_tty |
1147 // Too early to use gclog_or_tty |
1196 tty->print_cr("CMS set min_heap_size: " SIZE_FORMAT |
1148 tty->print_cr("CMS set min_heap_size: " SIZE_FORMAT |
1197 " initial_heap_size: " SIZE_FORMAT |
1149 " initial_heap_size: " SIZE_FORMAT |
1198 " max_heap: " SIZE_FORMAT, |
1150 " max_heap: " SIZE_FORMAT, |
1199 min_heap_size(), InitialHeapSize, max_heap); |
1151 min_heap_size(), InitialHeapSize, max_heap); |
1200 } |
1152 } |
1201 if (max_heap > min_new) { |
1153 size_t min_new = preferred_max_new_size; |
|
1154 if (FLAG_IS_CMDLINE(NewSize)) { |
|
1155 min_new = NewSize; |
|
1156 } |
|
1157 if (max_heap > min_new && min_heap_size() > min_new) { |
1202 // Unless explicitly requested otherwise, make young gen |
1158 // Unless explicitly requested otherwise, make young gen |
1203 // at least min_new, and at most preferred_max_new_size. |
1159 // at least min_new, and at most preferred_max_new_size. |
1204 if (FLAG_IS_DEFAULT(NewSize)) { |
1160 if (FLAG_IS_DEFAULT(NewSize)) { |
1205 FLAG_SET_ERGO(uintx, NewSize, MAX2(NewSize, min_new)); |
1161 FLAG_SET_ERGO(uintx, NewSize, MAX2(NewSize, min_new)); |
1206 FLAG_SET_ERGO(uintx, NewSize, MIN2(preferred_max_new_size, NewSize)); |
1162 FLAG_SET_ERGO(uintx, NewSize, MIN2(preferred_max_new_size, NewSize)); |
1207 if (PrintGCDetails && Verbose) { |
1163 if (PrintGCDetails && Verbose) { |
1208 // Too early to use gclog_or_tty |
1164 // Too early to use gclog_or_tty |
1209 tty->print_cr("Ergo set NewSize: " SIZE_FORMAT, NewSize); |
1165 tty->print_cr("CMS ergo set NewSize: " SIZE_FORMAT, NewSize); |
1210 } |
1166 } |
1211 } |
1167 } |
1212 // Unless explicitly requested otherwise, size old gen |
1168 // Unless explicitly requested otherwise, size old gen |
1213 // so that it's at least 3X of NewSize to begin with; |
1169 // so it's NewRatio x of NewSize. |
1214 // later NewRatio will decide how it grows; see above. |
|
1215 if (FLAG_IS_DEFAULT(OldSize)) { |
1170 if (FLAG_IS_DEFAULT(OldSize)) { |
1216 if (max_heap > NewSize) { |
1171 if (max_heap > NewSize) { |
1217 FLAG_SET_ERGO(uintx, OldSize, MIN2(3*NewSize, max_heap - NewSize)); |
1172 FLAG_SET_ERGO(uintx, OldSize, MIN2(NewRatio*NewSize, max_heap - NewSize)); |
1218 if (PrintGCDetails && Verbose) { |
1173 if (PrintGCDetails && Verbose) { |
1219 // Too early to use gclog_or_tty |
1174 // Too early to use gclog_or_tty |
1220 tty->print_cr("Ergo set OldSize: " SIZE_FORMAT, OldSize); |
1175 tty->print_cr("CMS ergo set OldSize: " SIZE_FORMAT, OldSize); |
1221 } |
1176 } |
1222 } |
1177 } |
1223 } |
1178 } |
1224 } |
1179 } |
1225 } |
1180 } |
3059 "Incompatible compilation policy selected", NULL); |
3014 "Incompatible compilation policy selected", NULL); |
3060 } |
3015 } |
3061 } |
3016 } |
3062 |
3017 |
3063 #ifndef KERNEL |
3018 #ifndef KERNEL |
3064 if (UseConcMarkSweepGC) { |
3019 // Set heap size based on available physical memory |
3065 // Set flags for CMS and ParNew. Check UseConcMarkSweep first |
3020 set_heap_size(); |
3066 // to ensure that when both UseConcMarkSweepGC and UseParNewGC |
3021 // Set per-collector flags |
3067 // are true, we don't call set_parnew_gc_flags() as well. |
3022 if (UseParallelGC || UseParallelOldGC) { |
|
3023 set_parallel_gc_flags(); |
|
3024 } else if (UseConcMarkSweepGC) { // should be done before ParNew check below |
3068 set_cms_and_parnew_gc_flags(); |
3025 set_cms_and_parnew_gc_flags(); |
3069 } else { |
3026 } else if (UseParNewGC) { // skipped if CMS is set above |
3070 // Set heap size based on available physical memory |
3027 set_parnew_gc_flags(); |
3071 set_heap_size(); |
3028 } else if (UseG1GC) { |
3072 // Set per-collector flags |
3029 set_g1_gc_flags(); |
3073 if (UseParallelGC || UseParallelOldGC) { |
|
3074 set_parallel_gc_flags(); |
|
3075 } else if (UseParNewGC) { |
|
3076 set_parnew_gc_flags(); |
|
3077 } else if (UseG1GC) { |
|
3078 set_g1_gc_flags(); |
|
3079 } |
|
3080 } |
3030 } |
3081 #endif // KERNEL |
3031 #endif // KERNEL |
3082 |
3032 |
3083 #ifdef SERIALGC |
3033 #ifdef SERIALGC |
3084 assert(verify_serial_gc_flags(), "SerialGC unset"); |
3034 assert(verify_serial_gc_flags(), "SerialGC unset"); |