Mercurial > hg > graal-jvmci-8
comparison src/share/vm/runtime/arguments.cpp @ 1064:473cce303f13
6887571: Increase default heap config sizes
Summary: Apply modification of existing server heap size ergo to all collectors except CMS.
Reviewed-by: jmasa, ysr, xlu
author | phh |
---|---|
date | Wed, 28 Oct 2009 16:25:51 -0400 |
parents | 354d3184f6b2 |
children | fb4c00faa9da |
comparison
equal
deleted
inserted
replaced
1035:a3b9e96881fe | 1064:473cce303f13 |
---|---|
35 char* Arguments::_java_command = NULL; | 35 char* Arguments::_java_command = NULL; |
36 SystemProperty* Arguments::_system_properties = NULL; | 36 SystemProperty* Arguments::_system_properties = NULL; |
37 const char* Arguments::_gc_log_filename = NULL; | 37 const char* Arguments::_gc_log_filename = NULL; |
38 bool Arguments::_has_profile = false; | 38 bool Arguments::_has_profile = false; |
39 bool Arguments::_has_alloc_profile = false; | 39 bool Arguments::_has_alloc_profile = false; |
40 uintx Arguments::_initial_heap_size = 0; | |
41 uintx Arguments::_min_heap_size = 0; | 40 uintx Arguments::_min_heap_size = 0; |
42 Arguments::Mode Arguments::_mode = _mixed; | 41 Arguments::Mode Arguments::_mode = _mixed; |
43 bool Arguments::_java_compiler = false; | 42 bool Arguments::_java_compiler = false; |
44 bool Arguments::_xdebug_mode = false; | 43 bool Arguments::_xdebug_mode = false; |
45 const char* Arguments::_java_vendor_url_bug = DEFAULT_VENDOR_URL_BUG; | 44 const char* Arguments::_java_vendor_url_bug = DEFAULT_VENDOR_URL_BUG; |
180 { "MaxTickInterval", JDK_Version::jdk(5), JDK_Version::jdk(7) }, | 179 { "MaxTickInterval", JDK_Version::jdk(5), JDK_Version::jdk(7) }, |
181 { "DelayTickAdjustment", JDK_Version::jdk(5), JDK_Version::jdk(7) }, | 180 { "DelayTickAdjustment", JDK_Version::jdk(5), JDK_Version::jdk(7) }, |
182 { "ProcessingToTenuringRatio", JDK_Version::jdk(5), JDK_Version::jdk(7) }, | 181 { "ProcessingToTenuringRatio", JDK_Version::jdk(5), JDK_Version::jdk(7) }, |
183 { "MinTrainLength", JDK_Version::jdk(5), JDK_Version::jdk(7) }, | 182 { "MinTrainLength", JDK_Version::jdk(5), JDK_Version::jdk(7) }, |
184 { "AppendRatio", JDK_Version::jdk_update(6,10), JDK_Version::jdk(7) }, | 183 { "AppendRatio", JDK_Version::jdk_update(6,10), JDK_Version::jdk(7) }, |
184 { "DefaultMaxRAM", JDK_Version::jdk_update(6,18), JDK_Version::jdk(7) }, | |
185 { "DefaultInitialRAMFraction", | |
186 JDK_Version::jdk_update(6,18), JDK_Version::jdk(7) }, | |
185 { NULL, JDK_Version(0), JDK_Version(0) } | 187 { NULL, JDK_Version(0), JDK_Version(0) } |
186 }; | 188 }; |
187 | 189 |
188 // Returns true if the flag is obsolete and fits into the range specified | 190 // Returns true if the flag is obsolete and fits into the range specified |
189 // for being ignored. In the case that the flag is ignored, the 'version' | 191 // for being ignored. In the case that the flag is ignored, the 'version' |
553 } | 555 } |
554 uintx uintx_v = (uintx) v; | 556 uintx uintx_v = (uintx) v; |
555 if (!is_neg && CommandLineFlags::uintxAtPut(name, &uintx_v, origin)) { | 557 if (!is_neg && CommandLineFlags::uintxAtPut(name, &uintx_v, origin)) { |
556 return true; | 558 return true; |
557 } | 559 } |
560 uint64_t uint64_t_v = (uint64_t) v; | |
561 if (!is_neg && CommandLineFlags::uint64_tAtPut(name, &uint64_t_v, origin)) { | |
562 return true; | |
563 } | |
558 return false; | 564 return false; |
559 } | 565 } |
560 | 566 |
561 static bool set_string_flag(char* name, const char* value, FlagValueOrigin origin) { | 567 static bool set_string_flag(char* name, const char* value, FlagValueOrigin origin) { |
562 if (!CommandLineFlags::ccstrAtPut(name, &value, origin)) return false; | 568 if (!CommandLineFlags::ccstrAtPut(name, &value, origin)) return false; |
945 // If the user has chosen ParallelGCThreads > 0, we set UseParNewGC | 951 // If the user has chosen ParallelGCThreads > 0, we set UseParNewGC |
946 // if it's not explictly set or unset. If the user has chosen | 952 // if it's not explictly set or unset. If the user has chosen |
947 // UseParNewGC and not explicitly set ParallelGCThreads we | 953 // UseParNewGC and not explicitly set ParallelGCThreads we |
948 // set it, unless this is a single cpu machine. | 954 // set it, unless this is a single cpu machine. |
949 void Arguments::set_parnew_gc_flags() { | 955 void Arguments::set_parnew_gc_flags() { |
950 assert(!UseSerialGC && !UseParallelGC && !UseG1GC, | 956 assert(!UseSerialGC && !UseParallelOldGC && !UseParallelGC && !UseG1GC, |
951 "control point invariant"); | 957 "control point invariant"); |
952 assert(UseParNewGC, "Error"); | 958 assert(UseParNewGC, "Error"); |
953 | 959 |
954 // Turn off AdaptiveSizePolicy by default for parnew until it is | 960 // Turn off AdaptiveSizePolicy by default for parnew until it is |
955 // complete. | 961 // complete. |
958 } | 964 } |
959 | 965 |
960 if (ParallelGCThreads == 0) { | 966 if (ParallelGCThreads == 0) { |
961 FLAG_SET_DEFAULT(ParallelGCThreads, | 967 FLAG_SET_DEFAULT(ParallelGCThreads, |
962 Abstract_VM_Version::parallel_worker_threads()); | 968 Abstract_VM_Version::parallel_worker_threads()); |
963 if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) { | 969 if (ParallelGCThreads == 1) { |
964 FLAG_SET_DEFAULT(UseParNewGC, false); | 970 FLAG_SET_DEFAULT(UseParNewGC, false); |
965 } | 971 FLAG_SET_DEFAULT(ParallelGCThreads, 0); |
966 } | 972 } |
967 if (!UseParNewGC) { | 973 } |
968 FLAG_SET_DEFAULT(ParallelGCThreads, 0); | 974 if (UseParNewGC) { |
969 } else { | 975 // CDS doesn't work with ParNew yet |
970 no_shared_spaces(); | 976 no_shared_spaces(); |
971 | 977 |
972 // By default YoungPLABSize and OldPLABSize are set to 4096 and 1024 respectively, | 978 // By default YoungPLABSize and OldPLABSize are set to 4096 and 1024 respectively, |
973 // these settings are default for Parallel Scavenger. For ParNew+Tenured configuration | 979 // these settings are default for Parallel Scavenger. For ParNew+Tenured configuration |
974 // we set them to 1024 and 1024. | 980 // we set them to 1024 and 1024. |
978 } | 984 } |
979 if (FLAG_IS_DEFAULT(OldPLABSize)) { | 985 if (FLAG_IS_DEFAULT(OldPLABSize)) { |
980 FLAG_SET_DEFAULT(OldPLABSize, (intx)1024); | 986 FLAG_SET_DEFAULT(OldPLABSize, (intx)1024); |
981 } | 987 } |
982 | 988 |
983 // AlwaysTenure flag should make ParNew to promote all at first collection. | 989 // AlwaysTenure flag should make ParNew promote all at first collection. |
984 // See CR 6362902. | 990 // See CR 6362902. |
985 if (AlwaysTenure) { | 991 if (AlwaysTenure) { |
986 FLAG_SET_CMDLINE(intx, MaxTenuringThreshold, 0); | 992 FLAG_SET_CMDLINE(intx, MaxTenuringThreshold, 0); |
987 } | 993 } |
988 // When using compressed oops, we use local overflow stacks, | 994 // When using compressed oops, we use local overflow stacks, |
1001 // Adjust some sizes to suit CMS and/or ParNew needs; these work well on | 1007 // Adjust some sizes to suit CMS and/or ParNew needs; these work well on |
1002 // sparc/solaris for certain applications, but would gain from | 1008 // sparc/solaris for certain applications, but would gain from |
1003 // further optimization and tuning efforts, and would almost | 1009 // further optimization and tuning efforts, and would almost |
1004 // certainly gain from analysis of platform and environment. | 1010 // certainly gain from analysis of platform and environment. |
1005 void Arguments::set_cms_and_parnew_gc_flags() { | 1011 void Arguments::set_cms_and_parnew_gc_flags() { |
1006 assert(!UseSerialGC && !UseParallelGC, "Error"); | 1012 assert(!UseSerialGC && !UseParallelOldGC && !UseParallelGC, "Error"); |
1007 assert(UseConcMarkSweepGC, "CMS is expected to be on here"); | 1013 assert(UseConcMarkSweepGC, "CMS is expected to be on here"); |
1008 | 1014 |
1009 // If we are using CMS, we prefer to UseParNewGC, | 1015 // If we are using CMS, we prefer to UseParNewGC, |
1010 // unless explicitly forbidden. | 1016 // unless explicitly forbidden. |
1011 if (FLAG_IS_DEFAULT(UseParNewGC)) { | 1017 if (FLAG_IS_DEFAULT(UseParNewGC)) { |
1066 if (!FLAG_IS_DEFAULT(NewSize)) { // NewSize explicitly set at command-line | 1072 if (!FLAG_IS_DEFAULT(NewSize)) { // NewSize explicitly set at command-line |
1067 FLAG_SET_ERGO(uintx, MaxNewSize, MAX2(NewSize, preferred_max_new_size)); | 1073 FLAG_SET_ERGO(uintx, MaxNewSize, MAX2(NewSize, preferred_max_new_size)); |
1068 } else { | 1074 } else { |
1069 FLAG_SET_ERGO(uintx, MaxNewSize, preferred_max_new_size); | 1075 FLAG_SET_ERGO(uintx, MaxNewSize, preferred_max_new_size); |
1070 } | 1076 } |
1071 if(PrintGCDetails && Verbose) { | 1077 if (PrintGCDetails && Verbose) { |
1072 // Too early to use gclog_or_tty | 1078 // Too early to use gclog_or_tty |
1073 tty->print_cr("Ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize); | 1079 tty->print_cr("Ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize); |
1074 } | 1080 } |
1075 | 1081 |
1076 // Unless explicitly requested otherwise, prefer a large | 1082 // Unless explicitly requested otherwise, prefer a large |
1095 min_new = align_size_up(ScaleForWordSize(min_new_default), | 1101 min_new = align_size_up(ScaleForWordSize(min_new_default), |
1096 os::vm_page_size()); | 1102 os::vm_page_size()); |
1097 } else { | 1103 } else { |
1098 min_new = NewSize; | 1104 min_new = NewSize; |
1099 } | 1105 } |
1100 size_t prev_initial_size = initial_heap_size(); | 1106 size_t prev_initial_size = InitialHeapSize; |
1101 if (prev_initial_size != 0 && prev_initial_size < min_new+OldSize) { | 1107 if (prev_initial_size != 0 && prev_initial_size < min_new + OldSize) { |
1102 set_initial_heap_size(min_new+OldSize); | 1108 FLAG_SET_ERGO(uintx, InitialHeapSize, min_new + OldSize); |
1103 // Currently minimum size and the initial heap sizes are the same. | 1109 // Currently minimum size and the initial heap sizes are the same. |
1104 set_min_heap_size(initial_heap_size()); | 1110 set_min_heap_size(InitialHeapSize); |
1105 if (PrintGCDetails && Verbose) { | 1111 if (PrintGCDetails && Verbose) { |
1106 warning("Initial heap size increased to " SIZE_FORMAT " M from " | 1112 warning("Initial heap size increased to " SIZE_FORMAT " M from " |
1107 SIZE_FORMAT " M; use -XX:NewSize=... for finer control.", | 1113 SIZE_FORMAT " M; use -XX:NewSize=... for finer control.", |
1108 initial_heap_size()/M, prev_initial_size/M); | 1114 InitialHeapSize/M, prev_initial_size/M); |
1109 } | 1115 } |
1110 } | 1116 } |
1111 | 1117 |
1112 // MaxHeapSize is aligned down in collectorPolicy | 1118 // MaxHeapSize is aligned down in collectorPolicy |
1113 size_t max_heap = | 1119 size_t max_heap = |
1114 align_size_down(MaxHeapSize, | 1120 align_size_down(MaxHeapSize, |
1115 CardTableRS::ct_max_alignment_constraint()); | 1121 CardTableRS::ct_max_alignment_constraint()); |
1116 | 1122 |
1117 if(PrintGCDetails && Verbose) { | 1123 if (PrintGCDetails && Verbose) { |
1118 // Too early to use gclog_or_tty | 1124 // Too early to use gclog_or_tty |
1119 tty->print_cr("CMS set min_heap_size: " SIZE_FORMAT | 1125 tty->print_cr("CMS set min_heap_size: " SIZE_FORMAT |
1120 " initial_heap_size: " SIZE_FORMAT | 1126 " initial_heap_size: " SIZE_FORMAT |
1121 " max_heap: " SIZE_FORMAT, | 1127 " max_heap: " SIZE_FORMAT, |
1122 min_heap_size(), initial_heap_size(), max_heap); | 1128 min_heap_size(), InitialHeapSize, max_heap); |
1123 } | 1129 } |
1124 if (max_heap > min_new) { | 1130 if (max_heap > min_new) { |
1125 // Unless explicitly requested otherwise, make young gen | 1131 // Unless explicitly requested otherwise, make young gen |
1126 // at least min_new, and at most preferred_max_new_size. | 1132 // at least min_new, and at most preferred_max_new_size. |
1127 if (FLAG_IS_DEFAULT(NewSize)) { | 1133 if (FLAG_IS_DEFAULT(NewSize)) { |
1128 FLAG_SET_ERGO(uintx, NewSize, MAX2(NewSize, min_new)); | 1134 FLAG_SET_ERGO(uintx, NewSize, MAX2(NewSize, min_new)); |
1129 FLAG_SET_ERGO(uintx, NewSize, MIN2(preferred_max_new_size, NewSize)); | 1135 FLAG_SET_ERGO(uintx, NewSize, MIN2(preferred_max_new_size, NewSize)); |
1130 if(PrintGCDetails && Verbose) { | 1136 if (PrintGCDetails && Verbose) { |
1131 // Too early to use gclog_or_tty | 1137 // Too early to use gclog_or_tty |
1132 tty->print_cr("Ergo set NewSize: " SIZE_FORMAT, NewSize); | 1138 tty->print_cr("Ergo set NewSize: " SIZE_FORMAT, NewSize); |
1133 } | 1139 } |
1134 } | 1140 } |
1135 // Unless explicitly requested otherwise, size old gen | 1141 // Unless explicitly requested otherwise, size old gen |
1136 // so that it's at least 3X of NewSize to begin with; | 1142 // so that it's at least 3X of NewSize to begin with; |
1137 // later NewRatio will decide how it grows; see above. | 1143 // later NewRatio will decide how it grows; see above. |
1138 if (FLAG_IS_DEFAULT(OldSize)) { | 1144 if (FLAG_IS_DEFAULT(OldSize)) { |
1139 if (max_heap > NewSize) { | 1145 if (max_heap > NewSize) { |
1140 FLAG_SET_ERGO(uintx, OldSize, MIN2(3*NewSize, max_heap - NewSize)); | 1146 FLAG_SET_ERGO(uintx, OldSize, MIN2(3*NewSize, max_heap - NewSize)); |
1141 if(PrintGCDetails && Verbose) { | 1147 if (PrintGCDetails && Verbose) { |
1142 // Too early to use gclog_or_tty | 1148 // Too early to use gclog_or_tty |
1143 tty->print_cr("Ergo set OldSize: " SIZE_FORMAT, OldSize); | 1149 tty->print_cr("Ergo set OldSize: " SIZE_FORMAT, OldSize); |
1144 } | 1150 } |
1145 } | 1151 } |
1146 } | 1152 } |
1184 } | 1190 } |
1185 } | 1191 } |
1186 | 1192 |
1187 inline uintx max_heap_for_compressed_oops() { | 1193 inline uintx max_heap_for_compressed_oops() { |
1188 LP64_ONLY(return oopDesc::OopEncodingHeapMax - MaxPermSize - os::vm_page_size()); | 1194 LP64_ONLY(return oopDesc::OopEncodingHeapMax - MaxPermSize - os::vm_page_size()); |
1189 NOT_LP64(return DefaultMaxRAM); | 1195 NOT_LP64(ShouldNotReachHere(); return 0); |
1190 } | 1196 } |
1191 | 1197 |
1192 bool Arguments::should_auto_select_low_pause_collector() { | 1198 bool Arguments::should_auto_select_low_pause_collector() { |
1193 if (UseAutoGCSelectPolicy && | 1199 if (UseAutoGCSelectPolicy && |
1194 !FLAG_IS_DEFAULT(MaxGCPauseMillis) && | 1200 !FLAG_IS_DEFAULT(MaxGCPauseMillis) && |
1203 return false; | 1209 return false; |
1204 } | 1210 } |
1205 | 1211 |
1206 void Arguments::set_ergonomics_flags() { | 1212 void Arguments::set_ergonomics_flags() { |
1207 // Parallel GC is not compatible with sharing. If one specifies | 1213 // Parallel GC is not compatible with sharing. If one specifies |
1208 // that they want sharing explicitly, do not set ergonmics flags. | 1214 // that they want sharing explicitly, do not set ergonomics flags. |
1209 if (DumpSharedSpaces || ForceSharedSpaces) { | 1215 if (DumpSharedSpaces || ForceSharedSpaces) { |
1210 return; | 1216 return; |
1211 } | 1217 } |
1212 | 1218 |
1213 if (os::is_server_class_machine() && !force_client_mode ) { | 1219 if (os::is_server_class_machine() && !force_client_mode ) { |
1269 // of the physical memory, up to a maximum of 1GB. | 1275 // of the physical memory, up to a maximum of 1GB. |
1270 if (UseParallelGC) { | 1276 if (UseParallelGC) { |
1271 FLAG_SET_ERGO(uintx, ParallelGCThreads, | 1277 FLAG_SET_ERGO(uintx, ParallelGCThreads, |
1272 Abstract_VM_Version::parallel_worker_threads()); | 1278 Abstract_VM_Version::parallel_worker_threads()); |
1273 | 1279 |
1274 // PS is a server collector, setup the heap sizes accordingly. | |
1275 set_server_heap_size(); | |
1276 // If InitialSurvivorRatio or MinSurvivorRatio were not specified, but the | 1280 // If InitialSurvivorRatio or MinSurvivorRatio were not specified, but the |
1277 // SurvivorRatio has been set, reset their default values to SurvivorRatio + | 1281 // SurvivorRatio has been set, reset their default values to SurvivorRatio + |
1278 // 2. By doing this we make SurvivorRatio also work for Parallel Scavenger. | 1282 // 2. By doing this we make SurvivorRatio also work for Parallel Scavenger. |
1279 // See CR 6362902 for details. | 1283 // See CR 6362902 for details. |
1280 if (!FLAG_IS_DEFAULT(SurvivorRatio)) { | 1284 if (!FLAG_IS_DEFAULT(SurvivorRatio)) { |
1300 } | 1304 } |
1301 } | 1305 } |
1302 | 1306 |
1303 void Arguments::set_g1_gc_flags() { | 1307 void Arguments::set_g1_gc_flags() { |
1304 assert(UseG1GC, "Error"); | 1308 assert(UseG1GC, "Error"); |
1305 // G1 is a server collector, setup the heap sizes accordingly. | |
1306 set_server_heap_size(); | |
1307 #ifdef COMPILER1 | 1309 #ifdef COMPILER1 |
1308 FastTLABRefill = false; | 1310 FastTLABRefill = false; |
1309 #endif | 1311 #endif |
1310 FLAG_SET_DEFAULT(ParallelGCThreads, | 1312 FLAG_SET_DEFAULT(ParallelGCThreads, |
1311 Abstract_VM_Version::parallel_worker_threads()); | 1313 Abstract_VM_Version::parallel_worker_threads()); |
1319 if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) { | 1321 if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) { |
1320 FLAG_SET_DEFAULT(MaxGCPauseMillis, 200); | 1322 FLAG_SET_DEFAULT(MaxGCPauseMillis, 200); |
1321 } | 1323 } |
1322 } | 1324 } |
1323 | 1325 |
1324 void Arguments::set_server_heap_size() { | 1326 void Arguments::set_heap_size() { |
1327 if (!FLAG_IS_DEFAULT(DefaultMaxRAMFraction)) { | |
1328 // Deprecated flag | |
1329 FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction); | |
1330 } | |
1331 | |
1332 const julong phys_mem = | |
1333 FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM) | |
1334 : (julong)MaxRAM; | |
1335 | |
1336 // If the maximum heap size has not been set with -Xmx, | |
1337 // then set it as fraction of the size of physical memory, | |
1338 // respecting the maximum and minimum sizes of the heap. | |
1325 if (FLAG_IS_DEFAULT(MaxHeapSize)) { | 1339 if (FLAG_IS_DEFAULT(MaxHeapSize)) { |
1326 const uint64_t reasonable_fraction = | 1340 julong reasonable_max = phys_mem / MaxRAMFraction; |
1327 os::physical_memory() / DefaultMaxRAMFraction; | 1341 |
1328 const uint64_t maximum_size = (uint64_t) | 1342 if (phys_mem <= MaxHeapSize * MinRAMFraction) { |
1329 (FLAG_IS_DEFAULT(DefaultMaxRAM) && UseCompressedOops ? | 1343 // Small physical memory, so use a minimum fraction of it for the heap |
1330 MIN2(max_heap_for_compressed_oops(), DefaultMaxRAM) : | 1344 reasonable_max = phys_mem / MinRAMFraction; |
1331 DefaultMaxRAM); | 1345 } else { |
1332 size_t reasonable_max = | 1346 // Not-small physical memory, so require a heap at least |
1333 (size_t) os::allocatable_physical_memory(reasonable_fraction); | 1347 // as large as MaxHeapSize |
1334 if (reasonable_max > maximum_size) { | 1348 reasonable_max = MAX2(reasonable_max, (julong)MaxHeapSize); |
1335 reasonable_max = maximum_size; | 1349 } |
1336 } | 1350 if (!FLAG_IS_DEFAULT(ErgoHeapSizeLimit) && ErgoHeapSizeLimit != 0) { |
1351 // Limit the heap size to ErgoHeapSizeLimit | |
1352 reasonable_max = MIN2(reasonable_max, (julong)ErgoHeapSizeLimit); | |
1353 } | |
1354 if (UseCompressedOops) { | |
1355 // Limit the heap size to the maximum possible when using compressed oops | |
1356 reasonable_max = MIN2(reasonable_max, (julong)max_heap_for_compressed_oops()); | |
1357 } | |
1358 reasonable_max = os::allocatable_physical_memory(reasonable_max); | |
1359 | |
1360 if (!FLAG_IS_DEFAULT(InitialHeapSize)) { | |
1361 // An initial heap size was specified on the command line, | |
1362 // so be sure that the maximum size is consistent. Done | |
1363 // after call to allocatable_physical_memory because that | |
1364 // method might reduce the allocation size. | |
1365 reasonable_max = MAX2(reasonable_max, (julong)InitialHeapSize); | |
1366 } | |
1367 | |
1337 if (PrintGCDetails && Verbose) { | 1368 if (PrintGCDetails && Verbose) { |
1338 // Cannot use gclog_or_tty yet. | 1369 // Cannot use gclog_or_tty yet. |
1339 tty->print_cr(" Max heap size for server class platform " | 1370 tty->print_cr(" Maximum heap size " SIZE_FORMAT, reasonable_max); |
1340 SIZE_FORMAT, reasonable_max); | 1371 } |
1341 } | 1372 FLAG_SET_ERGO(uintx, MaxHeapSize, (uintx)reasonable_max); |
1342 // If the initial_heap_size has not been set with -Xms, | 1373 } |
1343 // then set it as fraction of size of physical memory | 1374 |
1344 // respecting the maximum and minimum sizes of the heap. | 1375 // If the initial_heap_size has not been set with InitialHeapSize |
1345 if (initial_heap_size() == 0) { | 1376 // or -Xms, then set it as fraction of the size of physical memory, |
1346 const uint64_t reasonable_initial_fraction = | 1377 // respecting the maximum and minimum sizes of the heap. |
1347 os::physical_memory() / DefaultInitialRAMFraction; | 1378 if (FLAG_IS_DEFAULT(InitialHeapSize)) { |
1348 const size_t reasonable_initial = | 1379 julong reasonable_initial = phys_mem / InitialRAMFraction; |
1349 (size_t) os::allocatable_physical_memory(reasonable_initial_fraction); | 1380 |
1350 const size_t minimum_size = NewSize + OldSize; | 1381 reasonable_initial = MAX2(reasonable_initial, (julong)(OldSize + NewSize)); |
1351 set_initial_heap_size(MAX2(MIN2(reasonable_initial, reasonable_max), | 1382 reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize); |
1352 minimum_size)); | 1383 |
1353 // Currently the minimum size and the initial heap sizes are the same. | 1384 reasonable_initial = os::allocatable_physical_memory(reasonable_initial); |
1354 set_min_heap_size(initial_heap_size()); | 1385 |
1355 if (PrintGCDetails && Verbose) { | 1386 if (PrintGCDetails && Verbose) { |
1356 // Cannot use gclog_or_tty yet. | 1387 // Cannot use gclog_or_tty yet. |
1357 tty->print_cr(" Initial heap size for server class platform " | 1388 tty->print_cr(" Initial heap size " SIZE_FORMAT, (uintx)reasonable_initial); |
1358 SIZE_FORMAT, initial_heap_size()); | 1389 } |
1359 } | 1390 FLAG_SET_ERGO(uintx, InitialHeapSize, (uintx)reasonable_initial); |
1360 } else { | 1391 |
1361 // A minimum size was specified on the command line. Be sure | 1392 // Subsequent ergonomics code may expect min_heap_size to be set |
1362 // that the maximum size is consistent. | 1393 // if InitialHeapSize is. Use whatever the current values are |
1363 if (initial_heap_size() > reasonable_max) { | 1394 // for OldSize and NewSize, whether or not they were set on the |
1364 reasonable_max = initial_heap_size(); | 1395 // command line. |
1365 } | 1396 set_min_heap_size(OldSize + NewSize); |
1366 } | |
1367 FLAG_SET_ERGO(uintx, MaxHeapSize, (uintx) reasonable_max); | |
1368 } | 1397 } |
1369 } | 1398 } |
1370 | 1399 |
1371 // This must be called after ergonomics because we want bytecode rewriting | 1400 // This must be called after ergonomics because we want bytecode rewriting |
1372 // if the server compiler is used, or if UseSharedSpaces is disabled. | 1401 // if the server compiler is used, or if UseSharedSpaces is disabled. |
1446 "%s of " UINTX_FORMAT " is invalid; must be between 0 and 100\n", | 1475 "%s of " UINTX_FORMAT " is invalid; must be between 0 and 100\n", |
1447 name, value); | 1476 name, value); |
1448 return false; | 1477 return false; |
1449 } | 1478 } |
1450 | 1479 |
1451 static void set_serial_gc_flags() { | 1480 static void force_serial_gc() { |
1452 FLAG_SET_DEFAULT(UseSerialGC, true); | 1481 FLAG_SET_DEFAULT(UseSerialGC, true); |
1453 FLAG_SET_DEFAULT(UseParNewGC, false); | 1482 FLAG_SET_DEFAULT(UseParNewGC, false); |
1454 FLAG_SET_DEFAULT(UseConcMarkSweepGC, false); | 1483 FLAG_SET_DEFAULT(UseConcMarkSweepGC, false); |
1455 FLAG_SET_DEFAULT(CMSIncrementalMode, false); // special CMS suboption | 1484 FLAG_SET_DEFAULT(CMSIncrementalMode, false); // special CMS suboption |
1456 FLAG_SET_DEFAULT(UseParallelGC, false); | 1485 FLAG_SET_DEFAULT(UseParallelGC, false); |
1582 if (cannot_share) { | 1611 if (cannot_share) { |
1583 // Either force sharing on by forcing the other options off, or | 1612 // Either force sharing on by forcing the other options off, or |
1584 // force sharing off. | 1613 // force sharing off. |
1585 if (DumpSharedSpaces || ForceSharedSpaces) { | 1614 if (DumpSharedSpaces || ForceSharedSpaces) { |
1586 jio_fprintf(defaultStream::error_stream(), | 1615 jio_fprintf(defaultStream::error_stream(), |
1587 "Reverting to Serial GC because of %s \n", | 1616 "Reverting to Serial GC because of %s\n", |
1588 ForceSharedSpaces ? " -Xshare:on" : "-Xshare:dump"); | 1617 ForceSharedSpaces ? " -Xshare:on" : "-Xshare:dump"); |
1589 set_serial_gc_flags(); | 1618 force_serial_gc(); |
1590 FLAG_SET_DEFAULT(SOLARIS_ONLY(UseISM) NOT_SOLARIS(UseLargePages), false); | 1619 FLAG_SET_DEFAULT(SOLARIS_ONLY(UseISM) NOT_SOLARIS(UseLargePages), false); |
1591 } else { | 1620 } else { |
1592 if (UseSharedSpaces) { | 1621 if (UseSharedSpaces && Verbose) { |
1593 jio_fprintf(defaultStream::error_stream(), | 1622 jio_fprintf(defaultStream::error_stream(), |
1594 "Turning off use of shared archive because of " | 1623 "Turning off use of shared archive because of " |
1595 "choice of garbage collector or large pages \n"); | 1624 "choice of garbage collector or large pages\n"); |
1596 } | 1625 } |
1597 no_shared_spaces(); | 1626 no_shared_spaces(); |
1598 } | 1627 } |
1599 } | 1628 } |
1600 | 1629 |
1923 jio_fprintf(defaultStream::error_stream(), | 1952 jio_fprintf(defaultStream::error_stream(), |
1924 "Invalid initial eden size: %s\n", option->optionString); | 1953 "Invalid initial eden size: %s\n", option->optionString); |
1925 describe_range_error(errcode); | 1954 describe_range_error(errcode); |
1926 return JNI_EINVAL; | 1955 return JNI_EINVAL; |
1927 } | 1956 } |
1928 FLAG_SET_CMDLINE(uintx, MaxNewSize, (size_t) long_initial_eden_size); | 1957 FLAG_SET_CMDLINE(uintx, MaxNewSize, (uintx)long_initial_eden_size); |
1929 FLAG_SET_CMDLINE(uintx, NewSize, (size_t) long_initial_eden_size); | 1958 FLAG_SET_CMDLINE(uintx, NewSize, (uintx)long_initial_eden_size); |
1930 // -Xms | 1959 // -Xms |
1931 } else if (match_option(option, "-Xms", &tail)) { | 1960 } else if (match_option(option, "-Xms", &tail)) { |
1932 julong long_initial_heap_size = 0; | 1961 julong long_initial_heap_size = 0; |
1933 ArgsRange errcode = parse_memory_size(tail, &long_initial_heap_size, 1); | 1962 ArgsRange errcode = parse_memory_size(tail, &long_initial_heap_size, 1); |
1934 if (errcode != arg_in_range) { | 1963 if (errcode != arg_in_range) { |
1935 jio_fprintf(defaultStream::error_stream(), | 1964 jio_fprintf(defaultStream::error_stream(), |
1936 "Invalid initial heap size: %s\n", option->optionString); | 1965 "Invalid initial heap size: %s\n", option->optionString); |
1937 describe_range_error(errcode); | 1966 describe_range_error(errcode); |
1938 return JNI_EINVAL; | 1967 return JNI_EINVAL; |
1939 } | 1968 } |
1940 set_initial_heap_size((size_t) long_initial_heap_size); | 1969 FLAG_SET_CMDLINE(uintx, InitialHeapSize, (uintx)long_initial_heap_size); |
1941 // Currently the minimum size and the initial heap sizes are the same. | 1970 // Currently the minimum size and the initial heap sizes are the same. |
1942 set_min_heap_size(initial_heap_size()); | 1971 set_min_heap_size(InitialHeapSize); |
1943 // -Xmx | 1972 // -Xmx |
1944 } else if (match_option(option, "-Xmx", &tail)) { | 1973 } else if (match_option(option, "-Xmx", &tail)) { |
1945 julong long_max_heap_size = 0; | 1974 julong long_max_heap_size = 0; |
1946 ArgsRange errcode = parse_memory_size(tail, &long_max_heap_size, 1); | 1975 ArgsRange errcode = parse_memory_size(tail, &long_max_heap_size, 1); |
1947 if (errcode != arg_in_range) { | 1976 if (errcode != arg_in_range) { |
1948 jio_fprintf(defaultStream::error_stream(), | 1977 jio_fprintf(defaultStream::error_stream(), |
1949 "Invalid maximum heap size: %s\n", option->optionString); | 1978 "Invalid maximum heap size: %s\n", option->optionString); |
1950 describe_range_error(errcode); | 1979 describe_range_error(errcode); |
1951 return JNI_EINVAL; | 1980 return JNI_EINVAL; |
1952 } | 1981 } |
1953 FLAG_SET_CMDLINE(uintx, MaxHeapSize, (size_t) long_max_heap_size); | 1982 FLAG_SET_CMDLINE(uintx, MaxHeapSize, (uintx)long_max_heap_size); |
1954 // Xmaxf | 1983 // Xmaxf |
1955 } else if (match_option(option, "-Xmaxf", &tail)) { | 1984 } else if (match_option(option, "-Xmaxf", &tail)) { |
1956 int maxf = (int)(atof(tail) * 100); | 1985 int maxf = (int)(atof(tail) * 100); |
1957 if (maxf < 0 || maxf > 100) { | 1986 if (maxf < 0 || maxf > 100) { |
1958 jio_fprintf(defaultStream::error_stream(), | 1987 jio_fprintf(defaultStream::error_stream(), |
2194 warning("AggressiveHeap and MaxPermSize values may conflict"); | 2223 warning("AggressiveHeap and MaxPermSize values may conflict"); |
2195 } | 2224 } |
2196 | 2225 |
2197 if (FLAG_IS_DEFAULT(MaxHeapSize)) { | 2226 if (FLAG_IS_DEFAULT(MaxHeapSize)) { |
2198 FLAG_SET_CMDLINE(uintx, MaxHeapSize, initHeapSize); | 2227 FLAG_SET_CMDLINE(uintx, MaxHeapSize, initHeapSize); |
2199 set_initial_heap_size(MaxHeapSize); | 2228 FLAG_SET_CMDLINE(uintx, InitialHeapSize, initHeapSize); |
2200 // Currently the minimum size and the initial heap sizes are the same. | 2229 // Currently the minimum size and the initial heap sizes are the same. |
2201 set_min_heap_size(initial_heap_size()); | 2230 set_min_heap_size(initHeapSize); |
2202 } | 2231 } |
2203 if (FLAG_IS_DEFAULT(NewSize)) { | 2232 if (FLAG_IS_DEFAULT(NewSize)) { |
2204 // Make the young generation 3/8ths of the total heap. | 2233 // Make the young generation 3/8ths of the total heap. |
2205 FLAG_SET_CMDLINE(uintx, NewSize, | 2234 FLAG_SET_CMDLINE(uintx, NewSize, |
2206 ((julong)MaxHeapSize / (julong)8) * (julong)3); | 2235 ((julong)MaxHeapSize / (julong)8) * (julong)3); |
2674 TraceClassUnloading = true; | 2703 TraceClassUnloading = true; |
2675 } | 2704 } |
2676 } | 2705 } |
2677 | 2706 |
2678 #ifdef SERIALGC | 2707 #ifdef SERIALGC |
2679 set_serial_gc_flags(); | 2708 force_serial_gc(); |
2680 #endif // SERIALGC | 2709 #endif // SERIALGC |
2681 #ifdef KERNEL | 2710 #ifdef KERNEL |
2682 no_shared_spaces(); | 2711 no_shared_spaces(); |
2683 #endif // KERNEL | 2712 #endif // KERNEL |
2684 | 2713 |
2688 // Check the GC selections again. | 2717 // Check the GC selections again. |
2689 if (!check_gc_consistency()) { | 2718 if (!check_gc_consistency()) { |
2690 return JNI_EINVAL; | 2719 return JNI_EINVAL; |
2691 } | 2720 } |
2692 | 2721 |
2693 if (UseParallelGC || UseParallelOldGC) { | 2722 if (UseConcMarkSweepGC) { |
2694 // Set some flags for ParallelGC if needed. | 2723 // Set flags for CMS and ParNew. Check UseConcMarkSweep first |
2695 set_parallel_gc_flags(); | 2724 // to ensure that when both UseConcMarkSweepGC and UseParNewGC |
2696 } else if (UseConcMarkSweepGC) { | 2725 // are true, we don't call set_parnew_gc_flags() as well. |
2697 // Set some flags for CMS | |
2698 set_cms_and_parnew_gc_flags(); | 2726 set_cms_and_parnew_gc_flags(); |
2699 } else if (UseParNewGC) { | 2727 } else { |
2700 // Set some flags for ParNew | 2728 // Set heap size based on available physical memory |
2701 set_parnew_gc_flags(); | 2729 set_heap_size(); |
2702 } else if (UseG1GC) { | 2730 // Set per-collector flags |
2703 // Set some flags for garbage-first, if needed. | 2731 if (UseParallelGC || UseParallelOldGC) { |
2704 set_g1_gc_flags(); | 2732 set_parallel_gc_flags(); |
2733 } else if (UseParNewGC) { | |
2734 set_parnew_gc_flags(); | |
2735 } else if (UseG1GC) { | |
2736 set_g1_gc_flags(); | |
2737 } | |
2705 } | 2738 } |
2706 | 2739 |
2707 #ifdef SERIALGC | 2740 #ifdef SERIALGC |
2708 assert(verify_serial_gc_flags(), "SerialGC unset"); | 2741 assert(verify_serial_gc_flags(), "SerialGC unset"); |
2709 #endif // SERIALGC | 2742 #endif // SERIALGC |