hotspot/src/share/vm/gc/shared/plab.cpp
changeset 36390 a2d991d1d628
parent 35061 be6025ebffea
child 37068 fd8357c31be4
equal deleted inserted replaced
36389:1df45f48022b 36390:a2d991d1d628
     1 /*
     1 /*
     2  * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   108   } else {
   108   } else {
   109     add_undo_waste(obj, word_sz);
   109     add_undo_waste(obj, word_sz);
   110   }
   110   }
   111 }
   111 }
   112 
   112 
       
   113 void PLABStats::log_plab_allocation() {
       
   114   log_debug(gc, plab)("%s PLAB allocation: "
       
   115                       "allocated: " SIZE_FORMAT "B, "
       
   116                       "wasted: " SIZE_FORMAT "B, "
       
   117                       "unused: " SIZE_FORMAT "B, "
       
   118                       "used: " SIZE_FORMAT "B, "
       
   119                       "undo waste: " SIZE_FORMAT "B, ",
       
   120                       _description,
       
   121                       _allocated * HeapWordSize,
       
   122                       _wasted * HeapWordSize,
       
   123                       _unused * HeapWordSize,
       
   124                       used() * HeapWordSize,
       
   125                       _undo_wasted * HeapWordSize);
       
   126 }
       
   127 
       
   128 void PLABStats::log_sizing(size_t calculated_words, size_t net_desired_words) {
       
   129   log_debug(gc, plab)("%s sizing: "
       
   130                       "calculated: " SIZE_FORMAT "B, "
       
   131                       "actual: " SIZE_FORMAT "B",
       
   132                       _description,
       
   133                       calculated_words * HeapWordSize,
       
   134                       net_desired_words * HeapWordSize);
       
   135 }
       
   136 
   113 // Calculates plab size for current number of gc worker threads.
   137 // Calculates plab size for current number of gc worker threads.
   114 size_t PLABStats::desired_plab_sz(uint no_of_gc_workers) {
   138 size_t PLABStats::desired_plab_sz(uint no_of_gc_workers) {
   115   return MAX2(min_size(), (size_t)align_object_size(_desired_net_plab_sz / no_of_gc_workers));
   139   return MAX2(min_size(), (size_t)align_object_size(_desired_net_plab_sz / no_of_gc_workers));
   116 }
   140 }
   117 
   141 
   118 // Compute desired plab size for one gc worker thread and latch result for later
   142 // Compute desired plab size for one gc worker thread and latch result for later
   119 // use. This should be called once at the end of parallel
   143 // use. This should be called once at the end of parallel
   120 // scavenge; it clears the sensor accumulators.
   144 // scavenge; it clears the sensor accumulators.
   121 void PLABStats::adjust_desired_plab_sz() {
   145 void PLABStats::adjust_desired_plab_sz() {
   122   assert(ResizePLAB, "Not set");
   146   log_plab_allocation();
       
   147 
       
   148   if (!ResizePLAB) {
       
   149     // Clear accumulators for next round.
       
   150     reset();
       
   151     return;
       
   152   }
   123 
   153 
   124   assert(is_object_aligned(max_size()) && min_size() <= max_size(),
   154   assert(is_object_aligned(max_size()) && min_size() <= max_size(),
   125          "PLAB clipping computation may be incorrect");
   155          "PLAB clipping computation may be incorrect");
   126 
   156 
   127   if (_allocated == 0) {
   157   if (_allocated == 0) {
   148   // Clip from above and below, and align to object boundary
   178   // Clip from above and below, and align to object boundary
   149   size_t new_plab_sz = MAX2(min_size(), (size_t)_filter.average());
   179   size_t new_plab_sz = MAX2(min_size(), (size_t)_filter.average());
   150   new_plab_sz = MIN2(max_size(), new_plab_sz);
   180   new_plab_sz = MIN2(max_size(), new_plab_sz);
   151   new_plab_sz = align_object_size(new_plab_sz);
   181   new_plab_sz = align_object_size(new_plab_sz);
   152   // Latch the result
   182   // Latch the result
   153   log_trace(gc, plab)("plab_size = " SIZE_FORMAT " desired_net_plab_sz = " SIZE_FORMAT ") ", recent_plab_sz, new_plab_sz);
       
   154   _desired_net_plab_sz = new_plab_sz;
   183   _desired_net_plab_sz = new_plab_sz;
       
   184 
       
   185   log_sizing(recent_plab_sz, new_plab_sz);
   155 
   186 
   156   reset();
   187   reset();
   157 }
   188 }