src/share/vm/runtime/arguments.cpp

Print this page




1275   // Preferred young gen size for "short" pauses:
1276   // upper bound depends on # of threads and NewRatio.
1277   const uintx parallel_gc_threads =
1278     (ParallelGCThreads == 0 ? 1 : ParallelGCThreads);
1279   const size_t preferred_max_new_size_unaligned =
1280     MIN2(max_heap/(NewRatio+1), ScaleForWordSize(young_gen_per_worker * parallel_gc_threads));
1281   size_t preferred_max_new_size =
1282     align_size_up(preferred_max_new_size_unaligned, os::vm_page_size());
1283 
1284   // Unless explicitly requested otherwise, size young gen
1285   // for "short" pauses ~ CMSYoungGenPerWorker*ParallelGCThreads
1286 
1287   // If either MaxNewSize or NewRatio is set on the command line,
1288   // assume the user is trying to set the size of the young gen.
1289   if (FLAG_IS_DEFAULT(MaxNewSize) && FLAG_IS_DEFAULT(NewRatio)) {
1290 
1291     // Set MaxNewSize to our calculated preferred_max_new_size unless
1292     // NewSize was set on the command line and it is larger than
1293     // preferred_max_new_size.
1294     if (!FLAG_IS_DEFAULT(NewSize)) {   // NewSize explicitly set at command-line
1295       FLAG_SET_ERGO(uintx, MaxNewSize, MAX2(NewSize, preferred_max_new_size));
1296     } else {
1297       FLAG_SET_ERGO(uintx, MaxNewSize, preferred_max_new_size);
1298     }
1299     if (PrintGCDetails && Verbose) {
1300       // Too early to use gclog_or_tty
1301       tty->print_cr("CMS ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize);
1302     }
1303 
1304     // Code along this path potentially sets NewSize and OldSize
1305     if (PrintGCDetails && Verbose) {
1306       // Too early to use gclog_or_tty
1307       tty->print_cr("CMS set min_heap_size: " SIZE_FORMAT
1308            " initial_heap_size:  " SIZE_FORMAT
1309            " max_heap: " SIZE_FORMAT,
1310            min_heap_size(), InitialHeapSize, max_heap);
1311     }
1312     size_t min_new = preferred_max_new_size;
1313     if (FLAG_IS_CMDLINE(NewSize)) {
1314       min_new = NewSize;
1315     }
1316     if (max_heap > min_new && min_heap_size() > min_new) {
1317       // Unless explicitly requested otherwise, make young gen
1318       // at least min_new, and at most preferred_max_new_size.
1319       if (FLAG_IS_DEFAULT(NewSize)) {
1320         FLAG_SET_ERGO(uintx, NewSize, MAX2(NewSize, min_new));
1321         FLAG_SET_ERGO(uintx, NewSize, MIN2(preferred_max_new_size, NewSize));
1322         if (PrintGCDetails && Verbose) {
1323           // Too early to use gclog_or_tty
1324           tty->print_cr("CMS ergo set NewSize: " SIZE_FORMAT, NewSize);
1325         }
1326       }
1327       // Unless explicitly requested otherwise, size old gen
1328       // so it's NewRatio x of NewSize.
1329       if (FLAG_IS_DEFAULT(OldSize)) {
1330         if (max_heap > NewSize) {
1331           FLAG_SET_ERGO(uintx, OldSize, MIN2(NewRatio*NewSize, max_heap - NewSize));
1332           if (PrintGCDetails && Verbose) {
1333             // Too early to use gclog_or_tty
1334             tty->print_cr("CMS ergo set OldSize: " SIZE_FORMAT, OldSize);
1335           }
1336         }
1337       }
1338     }
1339   }
1340   // Unless explicitly requested otherwise, definitely
1341   // promote all objects surviving "tenuring_default" scavenges.
1342   if (FLAG_IS_DEFAULT(MaxTenuringThreshold) &&
1343       FLAG_IS_DEFAULT(SurvivorRatio)) {
1344     FLAG_SET_ERGO(uintx, MaxTenuringThreshold, tenuring_default);
1345   }
1346   // If we decided above (or user explicitly requested)
1347   // `promote all' (via MaxTenuringThreshold := 0),
1348   // prefer minuscule survivor spaces so as not to waste
1349   // space for (non-existent) survivors
1350   if (FLAG_IS_DEFAULT(SurvivorRatio) && MaxTenuringThreshold == 0) {
1351     FLAG_SET_ERGO(uintx, SurvivorRatio, MAX2((uintx)1024, SurvivorRatio));




1275   // Preferred young gen size for "short" pauses:
1276   // upper bound depends on # of threads and NewRatio.
1277   const uintx parallel_gc_threads =
1278     (ParallelGCThreads == 0 ? 1 : ParallelGCThreads);
1279   const size_t preferred_max_new_size_unaligned =
1280     MIN2(max_heap/(NewRatio+1), ScaleForWordSize(young_gen_per_worker * parallel_gc_threads));
1281   size_t preferred_max_new_size =
1282     align_size_up(preferred_max_new_size_unaligned, os::vm_page_size());
1283 
1284   // Unless explicitly requested otherwise, size young gen
1285   // for "short" pauses ~ CMSYoungGenPerWorker*ParallelGCThreads
1286 
1287   // If either MaxNewSize or NewRatio is set on the command line,
1288   // assume the user is trying to set the size of the young gen.
1289   if (FLAG_IS_DEFAULT(MaxNewSize) && FLAG_IS_DEFAULT(NewRatio)) {
1290 
1291     // Set MaxNewSize to our calculated preferred_max_new_size unless
1292     // NewSize was set on the command line and it is larger than
1293     // preferred_max_new_size.
1294     if (!FLAG_IS_DEFAULT(NewSize)) {   // NewSize explicitly set at command-line
1295       FLAG_SET_ERGO(uintx, MaxNewSize, MAX2(NewSize, (uintx)preferred_max_new_size));
1296     } else {
1297       FLAG_SET_ERGO(uintx, MaxNewSize, preferred_max_new_size);
1298     }
1299     if (PrintGCDetails && Verbose) {
1300       // Too early to use gclog_or_tty
1301       tty->print_cr("CMS ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize);
1302     }
1303 
1304     // Code along this path potentially sets NewSize and OldSize
1305     if (PrintGCDetails && Verbose) {
1306       // Too early to use gclog_or_tty
1307       tty->print_cr("CMS set min_heap_size: " SIZE_FORMAT
1308            " initial_heap_size:  " SIZE_FORMAT
1309            " max_heap: " SIZE_FORMAT,
1310            min_heap_size(), InitialHeapSize, max_heap);
1311     }
1312     size_t min_new = preferred_max_new_size;
1313     if (FLAG_IS_CMDLINE(NewSize)) {
1314       min_new = NewSize;
1315     }
1316     if (max_heap > min_new && min_heap_size() > min_new) {
1317       // Unless explicitly requested otherwise, make young gen
1318       // at least min_new, and at most preferred_max_new_size.
1319       if (FLAG_IS_DEFAULT(NewSize)) {
1320         FLAG_SET_ERGO(uintx, NewSize, MAX2(NewSize, (uintx)min_new));
1321         FLAG_SET_ERGO(uintx, NewSize, MIN2((uintx)preferred_max_new_size, NewSize));
1322         if (PrintGCDetails && Verbose) {
1323           // Too early to use gclog_or_tty
1324           tty->print_cr("CMS ergo set NewSize: " SIZE_FORMAT, NewSize);
1325         }
1326       }
1327       // Unless explicitly requested otherwise, size old gen
1328       // so it's NewRatio x of NewSize.
1329       if (FLAG_IS_DEFAULT(OldSize)) {
1330         if (max_heap > NewSize) {
1331           FLAG_SET_ERGO(uintx, OldSize, MIN2((NewRatio*NewSize), (uintx)(max_heap - NewSize)));
1332           if (PrintGCDetails && Verbose) {
1333             // Too early to use gclog_or_tty
1334             tty->print_cr("CMS ergo set OldSize: " SIZE_FORMAT, OldSize);
1335           }
1336         }
1337       }
1338     }
1339   }
1340   // Unless explicitly requested otherwise, definitely
1341   // promote all objects surviving "tenuring_default" scavenges.
1342   if (FLAG_IS_DEFAULT(MaxTenuringThreshold) &&
1343       FLAG_IS_DEFAULT(SurvivorRatio)) {
1344     FLAG_SET_ERGO(uintx, MaxTenuringThreshold, tenuring_default);
1345   }
1346   // If we decided above (or user explicitly requested)
1347   // `promote all' (via MaxTenuringThreshold := 0),
1348   // prefer minuscule survivor spaces so as not to waste
1349   // space for (non-existent) survivors
1350   if (FLAG_IS_DEFAULT(SurvivorRatio) && MaxTenuringThreshold == 0) {
1351     FLAG_SET_ERGO(uintx, SurvivorRatio, MAX2((uintx)1024, SurvivorRatio));