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

Split Close
Expand all
Collapse all
          --- old/src/share/vm/runtime/arguments.cpp
          +++ new/src/share/vm/runtime/arguments.cpp
↓ open down ↓ 1494 lines elided ↑ open up ↑
1495 1495  #ifdef COMPILER1
1496 1496    FastTLABRefill = false;
1497 1497  #endif
1498 1498    FLAG_SET_DEFAULT(ParallelGCThreads,
1499 1499                       Abstract_VM_Version::parallel_worker_threads());
1500 1500    if (ParallelGCThreads == 0) {
1501 1501      FLAG_SET_DEFAULT(ParallelGCThreads,
1502 1502                       Abstract_VM_Version::parallel_worker_threads());
1503 1503    }
1504 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);
     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);
1512 1511    }
1513 1512  
1514 1513    if (FLAG_IS_DEFAULT(GCTimeRatio) || GCTimeRatio == 0) {
1515 1514      // In G1, we want the default GC overhead goal to be higher than
1516 1515      // say in PS. So we set it here to 10%. Otherwise the heap might
1517 1516      // be expanded more aggressively than we would like it to. In
1518 1517      // fact, even 10% seems to not be high enough in some cases
1519 1518      // (especially small GC stress tests that the main thing they do
1520 1519      // is allocation). We might consider increase it further.
1521 1520      FLAG_SET_DEFAULT(GCTimeRatio, 9);
1522 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 +  }
1523 1528  }
1524 1529  
1525 1530  void Arguments::set_heap_size() {
1526 1531    if (!FLAG_IS_DEFAULT(DefaultMaxRAMFraction)) {
1527 1532      // Deprecated flag
1528 1533      FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction);
1529 1534    }
1530 1535  
1531 1536    const julong phys_mem =
1532 1537      FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
↓ open down ↓ 438 lines elided ↑ open up ↑
1971 1976    // Limit the lower bound of this flag to 1 as it is used in a division
1972 1977    // expression.
1973 1978    status = status && verify_interval(TLABWasteTargetPercent,
1974 1979                                       1, 100, "TLABWasteTargetPercent");
1975 1980  
1976 1981    status = status && verify_object_alignment();
1977 1982  
1978 1983    status = status && verify_min_value(ClassMetaspaceSize, 1*M,
1979 1984                                        "ClassMetaspaceSize");
1980 1985  
     1986 +  status = status && verify_interval(MarkStackSizeMax,
     1987 +                                  1, (max_jint - 1), "MarkStackSizeMax");
     1988 +
1981 1989  #ifdef SPARC
1982 1990    if (UseConcMarkSweepGC || UseG1GC) {
1983 1991      // Issue a stern warning if the user has explicitly set
1984 1992      // UseMemSetInBOT (it is known to cause issues), but allow
1985 1993      // use for experimentation and debugging.
1986 1994      if (VM_Version::is_sun4v() && UseMemSetInBOT) {
1987 1995        assert(!FLAG_IS_DEFAULT(UseMemSetInBOT), "Error");
1988 1996        warning("Experimental flag -XX:+UseMemSetInBOT is known to cause instability"
1989 1997            " on sun4v; please understand that you are using at your own risk!");
1990 1998      }
↓ open down ↓ 1464 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX