src/hotspot/share/gc/shenandoah/shenandoahArguments.cpp
changeset 58482 b4c660a75b54
parent 57977 42a13b4e9553
child 58679 9c3209ff7550
child 58989 f92ef5d182b5
equal deleted inserted replaced
58481:48a73ec3a817 58482:b4c660a75b54
    67 
    67 
    68   // Set up default number of concurrent threads. We want to have cycles complete fast
    68   // Set up default number of concurrent threads. We want to have cycles complete fast
    69   // enough, but we also do not want to steal too much CPU from the concurrently running
    69   // enough, but we also do not want to steal too much CPU from the concurrently running
    70   // application. Using 1/4 of available threads for concurrent GC seems a good
    70   // application. Using 1/4 of available threads for concurrent GC seems a good
    71   // compromise here.
    71   // compromise here.
    72   if (FLAG_IS_DEFAULT(ConcGCThreads)) {
    72   bool ergo_conc = FLAG_IS_DEFAULT(ConcGCThreads);
       
    73   if (ergo_conc) {
    73     FLAG_SET_DEFAULT(ConcGCThreads, MAX2(1, os::processor_count() / 4));
    74     FLAG_SET_DEFAULT(ConcGCThreads, MAX2(1, os::processor_count() / 4));
    74   }
    75   }
    75 
    76 
    76   if (ConcGCThreads == 0) {
    77   if (ConcGCThreads == 0) {
    77     vm_exit_during_initialization("Shenandoah expects ConcGCThreads > 0, check -XX:ConcGCThreads=#");
    78     vm_exit_during_initialization("Shenandoah expects ConcGCThreads > 0, check -XX:ConcGCThreads=#");
    80   // Set up default number of parallel threads. We want to have decent pauses performance
    81   // Set up default number of parallel threads. We want to have decent pauses performance
    81   // which would use parallel threads, but we also do not want to do too many threads
    82   // which would use parallel threads, but we also do not want to do too many threads
    82   // that will overwhelm the OS scheduler. Using 1/2 of available threads seems to be a fair
    83   // that will overwhelm the OS scheduler. Using 1/2 of available threads seems to be a fair
    83   // compromise here. Due to implementation constraints, it should not be lower than
    84   // compromise here. Due to implementation constraints, it should not be lower than
    84   // the number of concurrent threads.
    85   // the number of concurrent threads.
    85   if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
    86   bool ergo_parallel = FLAG_IS_DEFAULT(ParallelGCThreads);
       
    87   if (ergo_parallel) {
    86     FLAG_SET_DEFAULT(ParallelGCThreads, MAX2(1, os::processor_count() / 2));
    88     FLAG_SET_DEFAULT(ParallelGCThreads, MAX2(1, os::processor_count() / 2));
    87   }
    89   }
    88 
    90 
    89   if (ParallelGCThreads == 0) {
    91   if (ParallelGCThreads == 0) {
    90     vm_exit_during_initialization("Shenandoah expects ParallelGCThreads > 0, check -XX:ParallelGCThreads=#");
    92     vm_exit_during_initialization("Shenandoah expects ParallelGCThreads > 0, check -XX:ParallelGCThreads=#");
    91   }
    93   }
    92 
    94 
       
    95   // Make sure ergonomic decisions do not break the thread count invariants.
       
    96   // This may happen when user overrides one of the flags, but not the other.
       
    97   // When that happens, we want to adjust the setting that was set ergonomically.
    93   if (ParallelGCThreads < ConcGCThreads) {
    98   if (ParallelGCThreads < ConcGCThreads) {
    94     warning("Shenandoah expects ConcGCThreads <= ParallelGCThreads, adjusting ParallelGCThreads automatically");
    99     if (ergo_conc && !ergo_parallel) {
    95     FLAG_SET_DEFAULT(ParallelGCThreads, ConcGCThreads);
   100       FLAG_SET_DEFAULT(ConcGCThreads, ParallelGCThreads);
       
   101     } else if (!ergo_conc && ergo_parallel) {
       
   102       FLAG_SET_DEFAULT(ParallelGCThreads, ConcGCThreads);
       
   103     } else if (ergo_conc && ergo_parallel) {
       
   104       // Should not happen, check the ergonomic computation above. Fail with relevant error.
       
   105       vm_exit_during_initialization("Shenandoah thread count ergonomic error");
       
   106     } else {
       
   107       // User settings error, report and ask user to rectify.
       
   108       vm_exit_during_initialization("Shenandoah expects ConcGCThreads <= ParallelGCThreads, check -XX:ParallelGCThreads, -XX:ConcGCThreads");
       
   109     }
    96   }
   110   }
    97 
   111 
    98   if (FLAG_IS_DEFAULT(ParallelRefProcEnabled)) {
   112   if (FLAG_IS_DEFAULT(ParallelRefProcEnabled)) {
    99     FLAG_SET_DEFAULT(ParallelRefProcEnabled, true);
   113     FLAG_SET_DEFAULT(ParallelRefProcEnabled, true);
   100   }
   114   }