< prev index next >

src/hotspot/share/gc/g1/g1ConcurrentMark.cpp

Print this page
rev 47875 : 8190408: Run G1CMRemarkTask with the appropriate amount of threads instead of starting up everyone

Removing an if statement. The if-statement did safeguard that the
worker_id was always within the number of active tasks in _cm.

However the active number of tasks in _cm is set directly before the
remark task is created (set_concurrency_and_phase()). The value is
taken from the work gang (g1h->workers()->active_workers()). Thus, as
set_concurrency*() is not called during the actual remarking, the size
of the work-gang will be in sync with the _cm->active_tasks() -- at
least during the remark phase.

The code becomes somewhat easier to read, and hopefully one does not
get confused that we have too many threads running.

*** 1754,1785 **** class G1CMRemarkTask: public AbstractGangTask { private: G1ConcurrentMark* _cm; public: void work(uint worker_id) { ! // Since all available tasks are actually started, we should ! // only proceed if we're supposed to be active. ! if (worker_id < _cm->active_tasks()) { ! G1CMTask* task = _cm->task(worker_id); ! task->record_start_time(); ! { ! ResourceMark rm; ! HandleMark hm; ! G1RemarkThreadsClosure threads_f(G1CollectedHeap::heap(), task); ! Threads::threads_do(&threads_f); ! } ! ! do { ! task->do_marking_step(1000000000.0 /* something very large */, ! true /* do_termination */, ! false /* is_serial */); ! } while (task->has_aborted() && !_cm->has_overflown()); ! // If we overflow, then we do not want to restart. We instead ! // want to abort remark and do concurrent marking again. ! task->record_end_time(); } } G1CMRemarkTask(G1ConcurrentMark* cm, uint active_workers) : AbstractGangTask("Par Remark"), _cm(cm) { _cm->terminator()->reset_for_reuse(active_workers); --- 1754,1781 ---- class G1CMRemarkTask: public AbstractGangTask { private: G1ConcurrentMark* _cm; public: void work(uint worker_id) { ! G1CMTask* task = _cm->task(worker_id); ! task->record_start_time(); ! { ! ResourceMark rm; ! HandleMark hm; ! G1RemarkThreadsClosure threads_f(G1CollectedHeap::heap(), task); ! Threads::threads_do(&threads_f); } + + do { + task->do_marking_step(1000000000.0 /* something very large */, + true /* do_termination */, + false /* is_serial */); + } while (task->has_aborted() && !_cm->has_overflown()); + // If we overflow, then we do not want to restart. We instead + // want to abort remark and do concurrent marking again. + task->record_end_time(); } G1CMRemarkTask(G1ConcurrentMark* cm, uint active_workers) : AbstractGangTask("Par Remark"), _cm(cm) { _cm->terminator()->reset_for_reuse(active_workers);
< prev index next >