src/share/vm/memory/threadLocalAllocBuffer.cpp

Print this page




 221   _target_refills = 100 / (2 * TLABWasteTargetPercent);
 222   _target_refills = MAX2(_target_refills, (unsigned)1U);
 223 
 224   _global_stats = new GlobalTLABStats();
 225 
 226   // During jvm startup, the main (primordial) thread is initialized
 227   // before the heap is initialized.  So reinitialize it now.
 228   guarantee(Thread::current()->is_Java_thread(), "tlab initialization thread not Java thread");
 229   Thread::current()->tlab().initialize();
 230 
 231   if (PrintTLAB && Verbose) {
 232     gclog_or_tty->print("TLAB min: " SIZE_FORMAT " initial: " SIZE_FORMAT " max: " SIZE_FORMAT "\n",
 233                         min_size(), Thread::current()->tlab().initial_desired_size(), max_size());
 234   }
 235 }
 236 
 237 size_t ThreadLocalAllocBuffer::initial_desired_size() {
 238   size_t init_sz;
 239 
 240   if (TLABSize > 0) {
 241     init_sz = MIN2(TLABSize / HeapWordSize, max_size());
 242   } else if (global_stats() == NULL) {
 243     // Startup issue - main thread initialized before heap initialized.
 244     init_sz = min_size();
 245   } else {
 246     // Initial size is a function of the average number of allocating threads.
 247     unsigned nof_threads = global_stats()->allocating_threads_avg();
 248 
 249     init_sz  = (Universe::heap()->tlab_capacity(myThread()) / HeapWordSize) /
 250                       (nof_threads * target_refills());
 251     init_sz = align_object_size(init_sz);
 252     init_sz = MIN2(MAX2(init_sz, min_size()), max_size());
 253   }
 254   return init_sz;
 255 }
 256 
 257 void ThreadLocalAllocBuffer::print_stats(const char* tag) {
 258   Thread* thrd = myThread();
 259   size_t waste = _gc_waste + _slow_refill_waste + _fast_refill_waste;
 260   size_t alloc = _number_of_refills * _desired_size;
 261   double waste_percent = alloc == 0 ? 0.0 :




 221   _target_refills = 100 / (2 * TLABWasteTargetPercent);
 222   _target_refills = MAX2(_target_refills, (unsigned)1U);
 223 
 224   _global_stats = new GlobalTLABStats();
 225 
 226   // During jvm startup, the main (primordial) thread is initialized
 227   // before the heap is initialized.  So reinitialize it now.
 228   guarantee(Thread::current()->is_Java_thread(), "tlab initialization thread not Java thread");
 229   Thread::current()->tlab().initialize();
 230 
 231   if (PrintTLAB && Verbose) {
 232     gclog_or_tty->print("TLAB min: " SIZE_FORMAT " initial: " SIZE_FORMAT " max: " SIZE_FORMAT "\n",
 233                         min_size(), Thread::current()->tlab().initial_desired_size(), max_size());
 234   }
 235 }
 236 
 237 size_t ThreadLocalAllocBuffer::initial_desired_size() {
 238   size_t init_sz;
 239 
 240   if (TLABSize > 0) {
 241     init_sz = MIN2((size_t)(TLABSize / HeapWordSize), max_size());
 242   } else if (global_stats() == NULL) {
 243     // Startup issue - main thread initialized before heap initialized.
 244     init_sz = min_size();
 245   } else {
 246     // Initial size is a function of the average number of allocating threads.
 247     unsigned nof_threads = global_stats()->allocating_threads_avg();
 248 
 249     init_sz  = (Universe::heap()->tlab_capacity(myThread()) / HeapWordSize) /
 250                       (nof_threads * target_refills());
 251     init_sz = align_object_size(init_sz);
 252     init_sz = MIN2(MAX2(init_sz, min_size()), max_size());
 253   }
 254   return init_sz;
 255 }
 256 
 257 void ThreadLocalAllocBuffer::print_stats(const char* tag) {
 258   Thread* thrd = myThread();
 259   size_t waste = _gc_waste + _slow_refill_waste + _fast_refill_waste;
 260   size_t alloc = _number_of_refills * _desired_size;
 261   double waste_percent = alloc == 0 ? 0.0 :