< prev index next >
src/hotspot/share/gc/g1/g1ConcurrentRefine.cpp
Print this page
rev 47675 : [mq]: 8149127-rename-concurrentrefine-a
rev 47676 : imported patch 8149127-rename-concurrentrefine-b
rev 47677 : [mq]: 8149127-rename-concurrentrefine-b-stefanj-review
*** 1,7 ****
/*
! * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 21,32 ****
* questions.
*
*/
#include "precompiled.hpp"
! #include "gc/g1/concurrentG1Refine.hpp"
! #include "gc/g1/concurrentG1RefineThread.hpp"
#include "gc/g1/g1YoungRemSetSamplingThread.hpp"
#include "logging/log.hpp"
#include "runtime/java.hpp"
#include "runtime/thread.hpp"
#include "utilities/debug.hpp"
--- 21,32 ----
* questions.
*
*/
#include "precompiled.hpp"
! #include "gc/g1/g1ConcurrentRefine.hpp"
! #include "gc/g1/g1ConcurrentRefineThread.hpp"
#include "gc/g1/g1YoungRemSetSamplingThread.hpp"
#include "logging/log.hpp"
#include "runtime/java.hpp"
#include "runtime/thread.hpp"
#include "utilities/debug.hpp"
*** 95,105 ****
static Thresholds calc_thresholds(size_t green_zone,
size_t yellow_zone,
uint worker_i) {
double yellow_size = yellow_zone - green_zone;
! double step = yellow_size / ConcurrentG1Refine::thread_num();
if (worker_i == 0) {
// Potentially activate worker 0 more aggressively, to keep
// available buffers near green_zone value. When yellow_size is
// large we don't want to allow a full step to accumulate before
// doing any processing, as that might lead to significantly more
--- 95,105 ----
static Thresholds calc_thresholds(size_t green_zone,
size_t yellow_zone,
uint worker_i) {
double yellow_size = yellow_zone - green_zone;
! double step = yellow_size / G1ConcurrentRefine::thread_num();
if (worker_i == 0) {
// Potentially activate worker 0 more aggressively, to keep
// available buffers near green_zone value. When yellow_size is
// large we don't want to allow a full step to accumulate before
// doing any processing, as that might lead to significantly more
*** 110,120 ****
size_t deactivate_offset = static_cast<size_t>(floor(step * worker_i));
return Thresholds(green_zone + activate_offset,
green_zone + deactivate_offset);
}
! ConcurrentG1Refine::ConcurrentG1Refine(size_t green_zone,
size_t yellow_zone,
size_t red_zone,
size_t min_yellow_zone_size) :
_threads(NULL),
_sample_thread(NULL),
--- 110,120 ----
size_t deactivate_offset = static_cast<size_t>(floor(step * worker_i));
return Thresholds(green_zone + activate_offset,
green_zone + deactivate_offset);
}
! G1ConcurrentRefine::G1ConcurrentRefine(size_t green_zone,
size_t yellow_zone,
size_t red_zone,
size_t min_yellow_zone_size) :
_threads(NULL),
_sample_thread(NULL),
*** 127,137 ****
assert_zone_constraints_gyr(green_zone, yellow_zone, red_zone);
}
static size_t calc_min_yellow_zone_size() {
size_t step = G1ConcRefinementThresholdStep;
! uint n_workers = ConcurrentG1Refine::thread_num();
if ((max_yellow_zone / step) < n_workers) {
return max_yellow_zone;
} else {
return step * n_workers;
}
--- 127,137 ----
assert_zone_constraints_gyr(green_zone, yellow_zone, red_zone);
}
static size_t calc_min_yellow_zone_size() {
size_t step = G1ConcRefinementThresholdStep;
! uint n_workers = G1ConcurrentRefine::thread_num();
if ((max_yellow_zone / step) < n_workers) {
return max_yellow_zone;
} else {
return step * n_workers;
}
*** 167,177 ****
}
}
return MIN2(yellow + size, max_red_zone);
}
! ConcurrentG1Refine* ConcurrentG1Refine::create(jint* ecode) {
size_t min_yellow_zone_size = calc_min_yellow_zone_size();
size_t green_zone = calc_init_green_zone();
size_t yellow_zone = calc_init_yellow_zone(green_zone, min_yellow_zone_size);
size_t red_zone = calc_init_red_zone(green_zone, yellow_zone);
--- 167,177 ----
}
}
return MIN2(yellow + size, max_red_zone);
}
! G1ConcurrentRefine* G1ConcurrentRefine::create(jint* ecode) {
size_t min_yellow_zone_size = calc_min_yellow_zone_size();
size_t green_zone = calc_init_green_zone();
size_t yellow_zone = calc_init_yellow_zone(green_zone, min_yellow_zone_size);
size_t red_zone = calc_init_red_zone(green_zone, yellow_zone);
*** 180,282 ****
"yellow: " SIZE_FORMAT ", "
"red: " SIZE_FORMAT ", "
"min yellow size: " SIZE_FORMAT,
green_zone, yellow_zone, red_zone, min_yellow_zone_size);
! ConcurrentG1Refine* cg1r = new ConcurrentG1Refine(green_zone,
yellow_zone,
red_zone,
min_yellow_zone_size);
! if (cg1r == NULL) {
*ecode = JNI_ENOMEM;
! vm_shutdown_during_initialization("Could not create ConcurrentG1Refine");
return NULL;
}
! cg1r->_threads = NEW_C_HEAP_ARRAY_RETURN_NULL(ConcurrentG1RefineThread*, cg1r->_n_worker_threads, mtGC);
! if (cg1r->_threads == NULL) {
*ecode = JNI_ENOMEM;
! vm_shutdown_during_initialization("Could not allocate an array for ConcurrentG1RefineThread");
return NULL;
}
uint worker_id_offset = DirtyCardQueueSet::num_par_ids();
! ConcurrentG1RefineThread *next = NULL;
! for (uint i = cg1r->_n_worker_threads - 1; i != UINT_MAX; i--) {
Thresholds thresholds = calc_thresholds(green_zone, yellow_zone, i);
! ConcurrentG1RefineThread* t =
! new ConcurrentG1RefineThread(cg1r,
next,
worker_id_offset,
i,
activation_level(thresholds),
deactivation_level(thresholds));
assert(t != NULL, "Conc refine should have been created");
if (t->osthread() == NULL) {
*ecode = JNI_ENOMEM;
! vm_shutdown_during_initialization("Could not create ConcurrentG1RefineThread");
return NULL;
}
! assert(t->cg1r() == cg1r, "Conc refine thread should refer to this");
! cg1r->_threads[i] = t;
next = t;
}
! cg1r->_sample_thread = new G1YoungRemSetSamplingThread();
! if (cg1r->_sample_thread->osthread() == NULL) {
*ecode = JNI_ENOMEM;
vm_shutdown_during_initialization("Could not create G1YoungRemSetSamplingThread");
return NULL;
}
*ecode = JNI_OK;
! return cg1r;
}
! void ConcurrentG1Refine::stop() {
for (uint i = 0; i < _n_worker_threads; i++) {
_threads[i]->stop();
}
_sample_thread->stop();
}
! void ConcurrentG1Refine::update_thread_thresholds() {
for (uint i = 0; i < _n_worker_threads; i++) {
Thresholds thresholds = calc_thresholds(_green_zone, _yellow_zone, i);
_threads[i]->update_thresholds(activation_level(thresholds),
deactivation_level(thresholds));
}
}
! ConcurrentG1Refine::~ConcurrentG1Refine() {
for (uint i = 0; i < _n_worker_threads; i++) {
delete _threads[i];
}
! FREE_C_HEAP_ARRAY(ConcurrentG1RefineThread*, _threads);
delete _sample_thread;
}
! void ConcurrentG1Refine::threads_do(ThreadClosure *tc) {
worker_threads_do(tc);
tc->do_thread(_sample_thread);
}
! void ConcurrentG1Refine::worker_threads_do(ThreadClosure * tc) {
for (uint i = 0; i < _n_worker_threads; i++) {
tc->do_thread(_threads[i]);
}
}
! uint ConcurrentG1Refine::thread_num() {
return G1ConcRefinementThreads;
}
! void ConcurrentG1Refine::print_worker_threads_on(outputStream* st) const {
for (uint i = 0; i < _n_worker_threads; ++i) {
_threads[i]->print_on(st);
st->cr();
}
_sample_thread->print_on(st);
--- 180,282 ----
"yellow: " SIZE_FORMAT ", "
"red: " SIZE_FORMAT ", "
"min yellow size: " SIZE_FORMAT,
green_zone, yellow_zone, red_zone, min_yellow_zone_size);
! G1ConcurrentRefine* cr = new G1ConcurrentRefine(green_zone,
yellow_zone,
red_zone,
min_yellow_zone_size);
! if (cr == NULL) {
*ecode = JNI_ENOMEM;
! vm_shutdown_during_initialization("Could not create G1ConcurrentRefine");
return NULL;
}
! cr->_threads = NEW_C_HEAP_ARRAY_RETURN_NULL(G1ConcurrentRefineThread*, cr->_n_worker_threads, mtGC);
! if (cr->_threads == NULL) {
*ecode = JNI_ENOMEM;
! vm_shutdown_during_initialization("Could not allocate an array for G1ConcurrentRefineThread");
return NULL;
}
uint worker_id_offset = DirtyCardQueueSet::num_par_ids();
! G1ConcurrentRefineThread *next = NULL;
! for (uint i = cr->_n_worker_threads - 1; i != UINT_MAX; i--) {
Thresholds thresholds = calc_thresholds(green_zone, yellow_zone, i);
! G1ConcurrentRefineThread* t =
! new G1ConcurrentRefineThread(cr,
next,
worker_id_offset,
i,
activation_level(thresholds),
deactivation_level(thresholds));
assert(t != NULL, "Conc refine should have been created");
if (t->osthread() == NULL) {
*ecode = JNI_ENOMEM;
! vm_shutdown_during_initialization("Could not create G1ConcurrentRefineThread");
return NULL;
}
! assert(t->cr() == cr, "Conc refine thread should refer to this");
! cr->_threads[i] = t;
next = t;
}
! cr->_sample_thread = new G1YoungRemSetSamplingThread();
! if (cr->_sample_thread->osthread() == NULL) {
*ecode = JNI_ENOMEM;
vm_shutdown_during_initialization("Could not create G1YoungRemSetSamplingThread");
return NULL;
}
*ecode = JNI_OK;
! return cr;
}
! void G1ConcurrentRefine::stop() {
for (uint i = 0; i < _n_worker_threads; i++) {
_threads[i]->stop();
}
_sample_thread->stop();
}
! void G1ConcurrentRefine::update_thread_thresholds() {
for (uint i = 0; i < _n_worker_threads; i++) {
Thresholds thresholds = calc_thresholds(_green_zone, _yellow_zone, i);
_threads[i]->update_thresholds(activation_level(thresholds),
deactivation_level(thresholds));
}
}
! G1ConcurrentRefine::~G1ConcurrentRefine() {
for (uint i = 0; i < _n_worker_threads; i++) {
delete _threads[i];
}
! FREE_C_HEAP_ARRAY(G1ConcurrentRefineThread*, _threads);
delete _sample_thread;
}
! void G1ConcurrentRefine::threads_do(ThreadClosure *tc) {
worker_threads_do(tc);
tc->do_thread(_sample_thread);
}
! void G1ConcurrentRefine::worker_threads_do(ThreadClosure * tc) {
for (uint i = 0; i < _n_worker_threads; i++) {
tc->do_thread(_threads[i]);
}
}
! uint G1ConcurrentRefine::thread_num() {
return G1ConcRefinementThreads;
}
! void G1ConcurrentRefine::print_worker_threads_on(outputStream* st) const {
for (uint i = 0; i < _n_worker_threads; ++i) {
_threads[i]->print_on(st);
st->cr();
}
_sample_thread->print_on(st);
*** 310,320 ****
static size_t calc_new_red_zone(size_t green, size_t yellow) {
return MIN2(yellow + (yellow - green), max_red_zone);
}
! void ConcurrentG1Refine::update_zones(double update_rs_time,
size_t update_rs_processed_buffers,
double goal_ms) {
log_trace( CTRL_TAGS )("Updating Refinement Zones: "
"update_rs time: %.3fms, "
"update_rs buffers: " SIZE_FORMAT ", "
--- 310,320 ----
static size_t calc_new_red_zone(size_t green, size_t yellow) {
return MIN2(yellow + (yellow - green), max_red_zone);
}
! void G1ConcurrentRefine::update_zones(double update_rs_time,
size_t update_rs_processed_buffers,
double goal_ms) {
log_trace( CTRL_TAGS )("Updating Refinement Zones: "
"update_rs time: %.3fms, "
"update_rs buffers: " SIZE_FORMAT ", "
*** 336,346 ****
"yellow: " SIZE_FORMAT ", "
"red: " SIZE_FORMAT,
_green_zone, _yellow_zone, _red_zone);
}
! void ConcurrentG1Refine::adjust(double update_rs_time,
size_t update_rs_processed_buffers,
double goal_ms) {
DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
if (G1UseAdaptiveConcRefinement) {
--- 336,346 ----
"yellow: " SIZE_FORMAT ", "
"red: " SIZE_FORMAT,
_green_zone, _yellow_zone, _red_zone);
}
! void G1ConcurrentRefine::adjust(double update_rs_time,
size_t update_rs_processed_buffers,
double goal_ms) {
DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
if (G1UseAdaptiveConcRefinement) {
< prev index next >