234 guarantee(Thread::current()->is_Java_thread(), "tlab initialization thread not Java thread");
235 Thread::current()->tlab().initialize();
236
237 log_develop_trace(gc, tlab)("TLAB min: " SIZE_FORMAT " initial: " SIZE_FORMAT " max: " SIZE_FORMAT,
238 min_size(), Thread::current()->tlab().initial_desired_size(), max_size());
239 }
240
241 size_t ThreadLocalAllocBuffer::initial_desired_size() {
242 size_t init_sz = 0;
243
244 if (TLABSize > 0) {
245 init_sz = TLABSize / HeapWordSize;
246 } else {
247 // Initial size is a function of the average number of allocating threads.
248 unsigned int nof_threads = ThreadLocalAllocStats::allocating_threads_avg();
249
250 init_sz = (Universe::heap()->tlab_capacity(thread()) / HeapWordSize) /
251 (nof_threads * target_refills());
252 init_sz = align_object_size(init_sz);
253 }
254 // We can't use clamp() here because min_size() and max_size() because some
255 // options based on them may still be inconsistent; inconsistencies between
256 // those will be caught by following AfterMemoryInit constraint checking.
257 init_sz = MIN2(MAX2(init_sz, min_size()), max_size());
258 return init_sz;
259 }
260
261 void ThreadLocalAllocBuffer::print_stats(const char* tag) {
262 Log(gc, tlab) log;
263 if (!log.is_trace()) {
264 return;
265 }
266
267 Thread* thrd = thread();
268 size_t waste = _gc_waste + _slow_refill_waste + _fast_refill_waste;
269 double waste_percent = percent_of(waste, _allocated_size);
270 size_t tlab_used = Universe::heap()->tlab_used(thrd);
271 log.trace("TLAB: %s thread: " INTPTR_FORMAT " [id: %2d]"
272 " desired_size: " SIZE_FORMAT "KB"
273 " slow allocs: %d refill waste: " SIZE_FORMAT "B"
274 " alloc:%8.5f %8.0fKB refills: %d waste %4.1f%% gc: %dB"
|
234 guarantee(Thread::current()->is_Java_thread(), "tlab initialization thread not Java thread");
235 Thread::current()->tlab().initialize();
236
237 log_develop_trace(gc, tlab)("TLAB min: " SIZE_FORMAT " initial: " SIZE_FORMAT " max: " SIZE_FORMAT,
238 min_size(), Thread::current()->tlab().initial_desired_size(), max_size());
239 }
240
241 size_t ThreadLocalAllocBuffer::initial_desired_size() {
242 size_t init_sz = 0;
243
244 if (TLABSize > 0) {
245 init_sz = TLABSize / HeapWordSize;
246 } else {
247 // Initial size is a function of the average number of allocating threads.
248 unsigned int nof_threads = ThreadLocalAllocStats::allocating_threads_avg();
249
250 init_sz = (Universe::heap()->tlab_capacity(thread()) / HeapWordSize) /
251 (nof_threads * target_refills());
252 init_sz = align_object_size(init_sz);
253 }
254 // We can't use clamp() between min_size() and max_size() here because some
255 // options based on them may still be inconsistent; inconsistencies between
256 // those will be caught by following AfterMemoryInit constraint checking.
257 init_sz = MIN2(MAX2(init_sz, min_size()), max_size());
258 return init_sz;
259 }
260
261 void ThreadLocalAllocBuffer::print_stats(const char* tag) {
262 Log(gc, tlab) log;
263 if (!log.is_trace()) {
264 return;
265 }
266
267 Thread* thrd = thread();
268 size_t waste = _gc_waste + _slow_refill_waste + _fast_refill_waste;
269 double waste_percent = percent_of(waste, _allocated_size);
270 size_t tlab_used = Universe::heap()->tlab_used(thrd);
271 log.trace("TLAB: %s thread: " INTPTR_FORMAT " [id: %2d]"
272 " desired_size: " SIZE_FORMAT "KB"
273 " slow allocs: %d refill waste: " SIZE_FORMAT "B"
274 " alloc:%8.5f %8.0fKB refills: %d waste %4.1f%% gc: %dB"
|