< prev index next >

src/hotspot/share/gc/z/zHeuristics.cpp

Print this page




  32 #include "utilities/powerOfTwo.hpp"
  33 
  34 void ZHeuristics::set_medium_page_size() {
  35   // Set ZPageSizeMedium so that a medium page occupies at most 3.125% of the
  36   // max heap size. ZPageSizeMedium is initially set to 0, which means medium
  37   // pages are effectively disabled. It is adjusted only if ZPageSizeMedium
  38   // becomes larger than ZPageSizeSmall.
  39   const size_t min = ZGranuleSize;
  40   const size_t max = ZGranuleSize * 16;
  41   const size_t unclamped = MaxHeapSize * 0.03125;
  42   const size_t clamped = clamp(unclamped, min, max);
  43   const size_t size = round_down_power_of_2(clamped);
  44 
  45   if (size > ZPageSizeSmall) {
  46     // Enable medium pages
  47     ZPageSizeMedium             = size;
  48     ZPageSizeMediumShift        = log2_intptr(ZPageSizeMedium);
  49     ZObjectSizeLimitMedium      = ZPageSizeMedium / 8;
  50     ZObjectAlignmentMediumShift = (int)ZPageSizeMediumShift - 13;
  51     ZObjectAlignmentMedium      = 1 << ZObjectAlignmentMediumShift;
  52 
  53     log_info(gc, init)("Medium Page Size: " SIZE_FORMAT "M", ZPageSizeMedium / M);
  54   } else {
  55     log_info(gc, init)("Medium Page Size: N/A");
  56   }








  57 }
  58 
  59 bool ZHeuristics::use_per_cpu_shared_small_pages() {
  60   // Use per-CPU shared small pages only if these pages occupy at most 3.125%
  61   // of the max heap size. Otherwise fall back to using a single shared small
  62   // page. This is useful when using small heaps on large machines.
  63   const size_t per_cpu_share = (MaxHeapSize * 0.03125) / ZCPU::count();
  64   return per_cpu_share >= ZPageSizeSmall;
  65 }
  66 
  67 static uint nworkers_based_on_ncpus(double cpu_share_in_percent) {
  68   return ceil(os::initial_active_processor_count() * cpu_share_in_percent / 100.0);
  69 }
  70 
  71 static uint nworkers_based_on_heap_size(double reserve_share_in_percent) {
  72   const int nworkers = (MaxHeapSize * (reserve_share_in_percent / 100.0)) / ZPageSizeSmall;
  73   return MAX2(nworkers, 1);
  74 }
  75 
  76 static uint nworkers(double cpu_share_in_percent) {




  32 #include "utilities/powerOfTwo.hpp"
  33 
  34 void ZHeuristics::set_medium_page_size() {
  35   // Set ZPageSizeMedium so that a medium page occupies at most 3.125% of the
  36   // max heap size. ZPageSizeMedium is initially set to 0, which means medium
  37   // pages are effectively disabled. It is adjusted only if ZPageSizeMedium
  38   // becomes larger than ZPageSizeSmall.
  39   const size_t min = ZGranuleSize;
  40   const size_t max = ZGranuleSize * 16;
  41   const size_t unclamped = MaxHeapSize * 0.03125;
  42   const size_t clamped = clamp(unclamped, min, max);
  43   const size_t size = round_down_power_of_2(clamped);
  44 
  45   if (size > ZPageSizeSmall) {
  46     // Enable medium pages
  47     ZPageSizeMedium             = size;
  48     ZPageSizeMediumShift        = log2_intptr(ZPageSizeMedium);
  49     ZObjectSizeLimitMedium      = ZPageSizeMedium / 8;
  50     ZObjectAlignmentMediumShift = (int)ZPageSizeMediumShift - 13;
  51     ZObjectAlignmentMedium      = 1 << ZObjectAlignmentMediumShift;




  52   }
  53 }
  54 
  55 size_t ZHeuristics::max_reserve() {
  56   // Reserve one small page per worker plus one shared medium page. This is still just
  57   // an estimate and doesn't guarantee that we can't run out of memory during relocation.
  58   const uint nworkers = MAX2(ParallelGCThreads, ConcGCThreads);
  59   const size_t reserve = (nworkers * ZPageSizeSmall) + ZPageSizeMedium;
  60   return MIN2(MaxHeapSize, reserve);
  61 }
  62 
  63 bool ZHeuristics::use_per_cpu_shared_small_pages() {
  64   // Use per-CPU shared small pages only if these pages occupy at most 3.125%
  65   // of the max heap size. Otherwise fall back to using a single shared small
  66   // page. This is useful when using small heaps on large machines.
  67   const size_t per_cpu_share = (MaxHeapSize * 0.03125) / ZCPU::count();
  68   return per_cpu_share >= ZPageSizeSmall;
  69 }
  70 
  71 static uint nworkers_based_on_ncpus(double cpu_share_in_percent) {
  72   return ceil(os::initial_active_processor_count() * cpu_share_in_percent / 100.0);
  73 }
  74 
  75 static uint nworkers_based_on_heap_size(double reserve_share_in_percent) {
  76   const int nworkers = (MaxHeapSize * (reserve_share_in_percent / 100.0)) / ZPageSizeSmall;
  77   return MAX2(nworkers, 1);
  78 }
  79 
  80 static uint nworkers(double cpu_share_in_percent) {


< prev index next >