< prev index next >

src/hotspot/share/gc/shared/threadLocalAllocBuffer.hpp

Print this page
rev 48551 : [mq]: heap8
rev 48553 : [mq]: heap14_rebased
rev 48558 : [mq]: heap19
rev 48562 : [mq]: heap23
rev 48563 : [mq]: heap_to_thread
rev 48564 : [mq]: update-spec
rev 48565 : [mq]: event


  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_SHARED_THREADLOCALALLOCBUFFER_HPP
  26 #define SHARE_VM_GC_SHARED_THREADLOCALALLOCBUFFER_HPP
  27 
  28 #include "gc/shared/gcUtil.hpp"
  29 #include "oops/typeArrayOop.hpp"
  30 #include "runtime/perfData.hpp"
  31 #include "runtime/vm_version.hpp"
  32 
  33 class GlobalTLABStats;
  34 
  35 // ThreadLocalAllocBuffer: a descriptor for thread-local storage used by
  36 // the threads for allocation.
  37 //            It is thread-private at any time, but maybe multiplexed over
  38 //            time across multiple threads. The park()/unpark() pair is
  39 //            used to make it available for such multiplexing.
  40 //
  41 //            Heap sampling is performed via the end/actual_end fields.
  42 //            actual_end contains the real end of the tlab allocation,
  43 //            whereas end can be set to an arbitrary spot in the tlab to

  44 //            trip the return and sample the allocation.
  45 //            slow_path_end is used to track if a fast tlab refill occured
  46 //            between slowpath calls.
  47 class ThreadLocalAllocBuffer: public CHeapObj<mtThread> {
  48   friend class VMStructs;
  49   friend class JVMCIVMStructs;
  50 private:
  51   HeapWord* _start;                              // address of TLAB
  52   HeapWord* _top;                                // address after last allocation
  53   HeapWord* _pf_top;                             // allocation prefetch watermark
  54   HeapWord* _current_end;                        // allocation end (can be the sampling end point or _allocation_end)
  55   HeapWord* _allocation_end;                     // end for allocations (actual TLAB end, excluding alignment_reserve)
  56   HeapWord* _last_slow_path_end;                 // last address for slow_path_end (as opposed to _allocation_end)
  57 
  58   size_t    _desired_size;                       // desired size   (including alignment_reserve)
  59   size_t    _refill_waste_limit;                 // hold onto tlab if free() is larger than this
  60   size_t    _allocated_before_last_gc;           // total bytes allocated up until the last gc
  61   size_t    _bytes_since_last_sample_point;      // bytes since last sample point.
  62 
  63   static size_t   _max_size;                          // maximum size of any TLAB
  64   static int      _reserve_for_allocation_prefetch;   // Reserve at the end of the TLAB
  65   static unsigned _target_refills;                    // expected number of refills between GCs
  66 
  67   unsigned  _number_of_refills;
  68   unsigned  _fast_refill_waste;
  69   unsigned  _slow_refill_waste;
  70   unsigned  _gc_waste;
  71   unsigned  _slow_allocations;
  72 
  73   AdaptiveWeightedAverage _allocation_fraction;  // fraction of eden allocated in tlabs
  74 
  75   void accumulate_statistics();
  76   void initialize_statistics();
  77 
  78   void set_start(HeapWord* start)                { _start = start; }
  79   void set_current_end(HeapWord* current_end)    { _current_end = current_end; }
  80   void set_allocation_end(HeapWord* ptr)         { _allocation_end = ptr; }
  81   void set_last_slow_path_end(HeapWord* ptr)     { _last_slow_path_end = ptr; }
  82   void set_top(HeapWord* top)                    { _top = top; }
  83   void set_pf_top(HeapWord* pf_top)              { _pf_top = pf_top; }
  84   void set_desired_size(size_t desired_size)     { _desired_size = desired_size; }
  85   void set_refill_waste_limit(size_t waste)      { _refill_waste_limit = waste;  }
  86 
  87   size_t initial_refill_waste_limit()            { return desired_size() / TLABRefillWasteFraction; }
  88 
  89   static int    target_refills()                 { return _target_refills; }
  90   size_t initial_desired_size();
  91 
  92   size_t remaining();
  93 
  94   void update_end_pointers();
  95 
  96   // Make parsable and release it.
  97   void reset();
  98 
  99   // Resize based on amount of allocation, etc.
 100   void resize();
 101 




  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_SHARED_THREADLOCALALLOCBUFFER_HPP
  26 #define SHARE_VM_GC_SHARED_THREADLOCALALLOCBUFFER_HPP
  27 
  28 #include "gc/shared/gcUtil.hpp"
  29 #include "oops/typeArrayOop.hpp"
  30 #include "runtime/perfData.hpp"
  31 #include "runtime/vm_version.hpp"
  32 
  33 class GlobalTLABStats;
  34 
  35 // ThreadLocalAllocBuffer: a descriptor for thread-local storage used by
  36 // the threads for allocation.
  37 //            It is thread-private at any time, but maybe multiplexed over
  38 //            time across multiple threads. The park()/unpark() pair is
  39 //            used to make it available for such multiplexing.
  40 //
  41 //            Heap sampling is performed via the current_end/allocation_end
  42 //            fields.
  43 //            allocation_end contains the real end of the tlab allocation,
  44 //            whereas current_end can be set to an arbitrary spot in the tlab to
  45 //            trip the return and sample the allocation.


  46 class ThreadLocalAllocBuffer: public CHeapObj<mtThread> {
  47   friend class VMStructs;
  48   friend class JVMCIVMStructs;
  49 private:
  50   HeapWord* _start;                              // address of TLAB
  51   HeapWord* _top;                                // address after last allocation
  52   HeapWord* _pf_top;                             // allocation prefetch watermark
  53   HeapWord* _current_end;                        // allocation end (can be the sampling end point or _allocation_end)
  54   HeapWord* _allocation_end;                     // end for allocations (actual TLAB end, excluding alignment_reserve)

  55 
  56   size_t    _desired_size;                       // desired size   (including alignment_reserve)
  57   size_t    _refill_waste_limit;                 // hold onto tlab if free() is larger than this
  58   size_t    _allocated_before_last_gc;           // total bytes allocated up until the last gc
  59   size_t    _bytes_since_last_sample_point;      // bytes since last sample point.
  60 
  61   static size_t   _max_size;                          // maximum size of any TLAB
  62   static int      _reserve_for_allocation_prefetch;   // Reserve at the end of the TLAB
  63   static unsigned _target_refills;                    // expected number of refills between GCs
  64 
  65   unsigned  _number_of_refills;
  66   unsigned  _fast_refill_waste;
  67   unsigned  _slow_refill_waste;
  68   unsigned  _gc_waste;
  69   unsigned  _slow_allocations;
  70 
  71   AdaptiveWeightedAverage _allocation_fraction;  // fraction of eden allocated in tlabs
  72 
  73   void accumulate_statistics();
  74   void initialize_statistics();
  75 
  76   void set_start(HeapWord* start)                { _start = start; }
  77   void set_current_end(HeapWord* current_end)    { _current_end = current_end; }
  78   void set_allocation_end(HeapWord* ptr)         { _allocation_end = ptr; }

  79   void set_top(HeapWord* top)                    { _top = top; }
  80   void set_pf_top(HeapWord* pf_top)              { _pf_top = pf_top; }
  81   void set_desired_size(size_t desired_size)     { _desired_size = desired_size; }
  82   void set_refill_waste_limit(size_t waste)      { _refill_waste_limit = waste;  }
  83 
  84   size_t initial_refill_waste_limit()            { return desired_size() / TLABRefillWasteFraction; }
  85 
  86   static int    target_refills()                 { return _target_refills; }
  87   size_t initial_desired_size();
  88 
  89   size_t remaining();
  90 
  91   void update_end_pointers();
  92 
  93   // Make parsable and release it.
  94   void reset();
  95 
  96   // Resize based on amount of allocation, etc.
  97   void resize();
  98 


< prev index next >