src/share/vm/runtime/arguments.cpp

Print this page
rev 3708 : 8000244: G1: Ergonomically set MarkStackSize and use virtual space for global marking stack
Summary: Set the value of MarkStackSize to a value based on the number of parallel marking threads with a reasonable minimum. Expand the marking stack if we have to restart marking due to an overflow up to a reasonable maximum. Allocate the underlying space for the marking stack from virtual memory.
Reviewed-by: jmasa


1485       FLAG_SET_DEFAULT(MinHeapDeltaBytes, 64*M);
1486     }
1487     // For those collectors or operating systems (eg, Windows) that do
1488     // not support full UseNUMA, we will map to UseNUMAInterleaving for now
1489     UseNUMAInterleaving = true;
1490   }
1491 }
1492 
1493 void Arguments::set_g1_gc_flags() {
1494   assert(UseG1GC, "Error");
1495 #ifdef COMPILER1
1496   FastTLABRefill = false;
1497 #endif
1498   FLAG_SET_DEFAULT(ParallelGCThreads,
1499                      Abstract_VM_Version::parallel_worker_threads());
1500   if (ParallelGCThreads == 0) {
1501     FLAG_SET_DEFAULT(ParallelGCThreads,
1502                      Abstract_VM_Version::parallel_worker_threads());
1503   }
1504 
1505   if (FLAG_IS_DEFAULT(MarkStackSize)) {
1506     FLAG_SET_DEFAULT(MarkStackSize, 128 * TASKQUEUE_SIZE);
1507   }
1508   if (PrintGCDetails && Verbose) {
1509     tty->print_cr("MarkStackSize: %uk  MarkStackSizeMax: %uk",
1510       MarkStackSize / K, MarkStackSizeMax / K);
1511     tty->print_cr("ConcGCThreads: %u", ConcGCThreads);
1512   }
1513 
1514   if (FLAG_IS_DEFAULT(GCTimeRatio) || GCTimeRatio == 0) {
1515     // In G1, we want the default GC overhead goal to be higher than
1516     // say in PS. So we set it here to 10%. Otherwise the heap might
1517     // be expanded more aggressively than we would like it to. In
1518     // fact, even 10% seems to not be high enough in some cases
1519     // (especially small GC stress tests that the main thing they do
1520     // is allocation). We might consider increase it further.
1521     FLAG_SET_DEFAULT(GCTimeRatio, 9);
1522   }






1523 }
1524 
1525 void Arguments::set_heap_size() {
1526   if (!FLAG_IS_DEFAULT(DefaultMaxRAMFraction)) {
1527     // Deprecated flag
1528     FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction);
1529   }
1530 
1531   const julong phys_mem =
1532     FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
1533                             : (julong)MaxRAM;
1534 
1535   // If the maximum heap size has not been set with -Xmx,
1536   // then set it as fraction of the size of physical memory,
1537   // respecting the maximum and minimum sizes of the heap.
1538   if (FLAG_IS_DEFAULT(MaxHeapSize)) {
1539     julong reasonable_max = phys_mem / MaxRAMFraction;
1540 
1541     if (phys_mem <= MaxHeapSize * MinRAMFraction) {
1542       // Small physical memory, so use a minimum fraction of it for the heap


1961     status = status && verify_min_value((intx)G1ConcMarkStepDurationMillis, 1,
1962                                         "G1ConcMarkStepDurationMillis");
1963   }
1964 #endif
1965 
1966   status = status && verify_interval(RefDiscoveryPolicy,
1967                                      ReferenceProcessor::DiscoveryPolicyMin,
1968                                      ReferenceProcessor::DiscoveryPolicyMax,
1969                                      "RefDiscoveryPolicy");
1970 
1971   // Limit the lower bound of this flag to 1 as it is used in a division
1972   // expression.
1973   status = status && verify_interval(TLABWasteTargetPercent,
1974                                      1, 100, "TLABWasteTargetPercent");
1975 
1976   status = status && verify_object_alignment();
1977 
1978   status = status && verify_min_value(ClassMetaspaceSize, 1*M,
1979                                       "ClassMetaspaceSize");
1980 



1981 #ifdef SPARC
1982   if (UseConcMarkSweepGC || UseG1GC) {
1983     // Issue a stern warning if the user has explicitly set
1984     // UseMemSetInBOT (it is known to cause issues), but allow
1985     // use for experimentation and debugging.
1986     if (VM_Version::is_sun4v() && UseMemSetInBOT) {
1987       assert(!FLAG_IS_DEFAULT(UseMemSetInBOT), "Error");
1988       warning("Experimental flag -XX:+UseMemSetInBOT is known to cause instability"
1989           " on sun4v; please understand that you are using at your own risk!");
1990     }
1991   }
1992 #endif // SPARC
1993 
1994   if (PrintNMTStatistics && MemTracker::tracking_level() == MemTracker::NMT_off) {
1995     warning("PrintNMTStatistics is disabled, because native memory tracking is not enabled");
1996     PrintNMTStatistics = false;
1997   }
1998 
1999   return status;
2000 }




1485       FLAG_SET_DEFAULT(MinHeapDeltaBytes, 64*M);
1486     }
1487     // For those collectors or operating systems (eg, Windows) that do
1488     // not support full UseNUMA, we will map to UseNUMAInterleaving for now
1489     UseNUMAInterleaving = true;
1490   }
1491 }
1492 
1493 void Arguments::set_g1_gc_flags() {
1494   assert(UseG1GC, "Error");
1495 #ifdef COMPILER1
1496   FastTLABRefill = false;
1497 #endif
1498   FLAG_SET_DEFAULT(ParallelGCThreads,
1499                      Abstract_VM_Version::parallel_worker_threads());
1500   if (ParallelGCThreads == 0) {
1501     FLAG_SET_DEFAULT(ParallelGCThreads,
1502                      Abstract_VM_Version::parallel_worker_threads());
1503   }
1504 
1505   // MarkStackSize will be set (if it hasn't been set by the user)
1506   // when concurrent marking is initialized.
1507   // Its value will be based upon the number of parallel marking threads.
1508   // But we do set the maximum mark stack size here.
1509   if (FLAG_IS_DEFAULT(MarkStackSizeMax)) {
1510     FLAG_SET_DEFAULT(MarkStackSizeMax, 128 * TASKQUEUE_SIZE);

1511   }
1512 
1513   if (FLAG_IS_DEFAULT(GCTimeRatio) || GCTimeRatio == 0) {
1514     // In G1, we want the default GC overhead goal to be higher than
1515     // say in PS. So we set it here to 10%. Otherwise the heap might
1516     // be expanded more aggressively than we would like it to. In
1517     // fact, even 10% seems to not be high enough in some cases
1518     // (especially small GC stress tests that the main thing they do
1519     // is allocation). We might consider increase it further.
1520     FLAG_SET_DEFAULT(GCTimeRatio, 9);
1521   }
1522 
1523   if (PrintGCDetails && Verbose) {
1524     tty->print_cr("MarkStackSize: %uk  MarkStackSizeMax: %uk",
1525       MarkStackSize / K, MarkStackSizeMax / K);
1526     tty->print_cr("ConcGCThreads: %u", ConcGCThreads);
1527   }
1528 }
1529 
1530 void Arguments::set_heap_size() {
1531   if (!FLAG_IS_DEFAULT(DefaultMaxRAMFraction)) {
1532     // Deprecated flag
1533     FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction);
1534   }
1535 
1536   const julong phys_mem =
1537     FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
1538                             : (julong)MaxRAM;
1539 
1540   // If the maximum heap size has not been set with -Xmx,
1541   // then set it as fraction of the size of physical memory,
1542   // respecting the maximum and minimum sizes of the heap.
1543   if (FLAG_IS_DEFAULT(MaxHeapSize)) {
1544     julong reasonable_max = phys_mem / MaxRAMFraction;
1545 
1546     if (phys_mem <= MaxHeapSize * MinRAMFraction) {
1547       // Small physical memory, so use a minimum fraction of it for the heap


1966     status = status && verify_min_value((intx)G1ConcMarkStepDurationMillis, 1,
1967                                         "G1ConcMarkStepDurationMillis");
1968   }
1969 #endif
1970 
1971   status = status && verify_interval(RefDiscoveryPolicy,
1972                                      ReferenceProcessor::DiscoveryPolicyMin,
1973                                      ReferenceProcessor::DiscoveryPolicyMax,
1974                                      "RefDiscoveryPolicy");
1975 
1976   // Limit the lower bound of this flag to 1 as it is used in a division
1977   // expression.
1978   status = status && verify_interval(TLABWasteTargetPercent,
1979                                      1, 100, "TLABWasteTargetPercent");
1980 
1981   status = status && verify_object_alignment();
1982 
1983   status = status && verify_min_value(ClassMetaspaceSize, 1*M,
1984                                       "ClassMetaspaceSize");
1985 
1986   status = status && verify_interval(MarkStackSizeMax,
1987                                   1, (max_jint - 1), "MarkStackSizeMax");
1988 
1989 #ifdef SPARC
1990   if (UseConcMarkSweepGC || UseG1GC) {
1991     // Issue a stern warning if the user has explicitly set
1992     // UseMemSetInBOT (it is known to cause issues), but allow
1993     // use for experimentation and debugging.
1994     if (VM_Version::is_sun4v() && UseMemSetInBOT) {
1995       assert(!FLAG_IS_DEFAULT(UseMemSetInBOT), "Error");
1996       warning("Experimental flag -XX:+UseMemSetInBOT is known to cause instability"
1997           " on sun4v; please understand that you are using at your own risk!");
1998     }
1999   }
2000 #endif // SPARC
2001 
2002   if (PrintNMTStatistics && MemTracker::tracking_level() == MemTracker::NMT_off) {
2003     warning("PrintNMTStatistics is disabled, because native memory tracking is not enabled");
2004     PrintNMTStatistics = false;
2005   }
2006 
2007   return status;
2008 }