mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 01:54:47 +02:00
8224664: Parallel GC: Use WorkGang (6: PSRefProcTaskProxy)
Reviewed-by: stefank, kbarrett, tschatzl
This commit is contained in:
parent
82b140f83d
commit
fd1966fa3a
5 changed files with 32 additions and 185 deletions
|
@ -29,7 +29,6 @@
|
|||
#include "gc/parallel/psCardTable.hpp"
|
||||
#include "gc/parallel/psPromotionManager.inline.hpp"
|
||||
#include "gc/parallel/psScavenge.inline.hpp"
|
||||
#include "gc/parallel/psTasks.hpp"
|
||||
#include "gc/parallel/psYoungGen.hpp"
|
||||
#include "memory/iterator.inline.hpp"
|
||||
#include "oops/access.inline.hpp"
|
||||
|
|
|
@ -53,6 +53,8 @@ class PSPromotionManager {
|
|||
friend class PSScavenge;
|
||||
friend class ScavengeRootsTask;
|
||||
friend class PSRefProcTaskExecutor;
|
||||
friend class PSRefProcTask;
|
||||
|
||||
private:
|
||||
static PaddedEnd<PSPromotionManager>* _manager_array;
|
||||
static OopStarTaskQueueSet* _stack_array_depth;
|
||||
|
|
|
@ -31,12 +31,12 @@
|
|||
#include "gc/parallel/parallelScavengeHeap.hpp"
|
||||
#include "gc/parallel/psAdaptiveSizePolicy.hpp"
|
||||
#include "gc/parallel/psClosure.inline.hpp"
|
||||
#include "gc/parallel/psCompactionManager.hpp"
|
||||
#include "gc/parallel/psMarkSweepProxy.hpp"
|
||||
#include "gc/parallel/psParallelCompact.inline.hpp"
|
||||
#include "gc/parallel/psPromotionManager.inline.hpp"
|
||||
#include "gc/parallel/psRootType.hpp"
|
||||
#include "gc/parallel/psScavenge.inline.hpp"
|
||||
#include "gc/parallel/psTasks.hpp"
|
||||
#include "gc/shared/gcCause.hpp"
|
||||
#include "gc/shared/gcHeapSummary.hpp"
|
||||
#include "gc/shared/gcId.hpp"
|
||||
|
@ -213,57 +213,42 @@ class PSEvacuateFollowersClosure: public VoidClosure {
|
|||
}
|
||||
};
|
||||
|
||||
class PSRefProcTaskProxy: public GCTask {
|
||||
typedef AbstractRefProcTaskExecutor::ProcessTask ProcessTask;
|
||||
ProcessTask & _rp_task;
|
||||
uint _work_id;
|
||||
public:
|
||||
PSRefProcTaskProxy(ProcessTask & rp_task, uint work_id)
|
||||
: _rp_task(rp_task),
|
||||
_work_id(work_id)
|
||||
{ }
|
||||
|
||||
private:
|
||||
virtual char* name() { return (char *)"Process referents by policy in parallel"; }
|
||||
virtual void do_it(GCTaskManager* manager, uint which);
|
||||
class PSRefProcTaskExecutor: public AbstractRefProcTaskExecutor {
|
||||
virtual void execute(ProcessTask& process_task, uint ergo_workers);
|
||||
};
|
||||
|
||||
void PSRefProcTaskProxy::do_it(GCTaskManager* manager, uint which)
|
||||
{
|
||||
class PSRefProcTask : public AbstractGangTask {
|
||||
typedef AbstractRefProcTaskExecutor::ProcessTask ProcessTask;
|
||||
TaskTerminator _terminator;
|
||||
ProcessTask& _task;
|
||||
uint _active_workers;
|
||||
|
||||
public:
|
||||
PSRefProcTask(ProcessTask& task, uint active_workers)
|
||||
: AbstractGangTask("PSRefProcTask"),
|
||||
_terminator(active_workers, PSPromotionManager::stack_array_depth()),
|
||||
_task(task),
|
||||
_active_workers(active_workers) {
|
||||
}
|
||||
|
||||
virtual void work(uint worker_id) {
|
||||
PSPromotionManager* promotion_manager =
|
||||
PSPromotionManager::gc_thread_promotion_manager(which);
|
||||
PSPromotionManager::gc_thread_promotion_manager(worker_id);
|
||||
assert(promotion_manager != NULL, "sanity check");
|
||||
PSKeepAliveClosure keep_alive(promotion_manager);
|
||||
PSEvacuateFollowersClosure evac_followers(promotion_manager);
|
||||
PSIsAliveClosure is_alive;
|
||||
_rp_task.work(_work_id, is_alive, keep_alive, evac_followers);
|
||||
}
|
||||
_task.work(worker_id, is_alive, keep_alive, evac_followers);
|
||||
|
||||
class PSRefProcTaskExecutor: public AbstractRefProcTaskExecutor {
|
||||
virtual void execute(ProcessTask& task, uint ergo_workers);
|
||||
if (_task.marks_oops_alive() && _active_workers > 1) {
|
||||
steal_work(*_terminator.terminator(), worker_id);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void PSRefProcTaskExecutor::execute(ProcessTask& task, uint ergo_workers)
|
||||
{
|
||||
GCTaskQueue* q = GCTaskQueue::create();
|
||||
GCTaskManager* manager = ParallelScavengeHeap::gc_task_manager();
|
||||
uint active_workers = manager->active_workers();
|
||||
|
||||
assert(active_workers == ergo_workers,
|
||||
"Ergonomically chosen workers (%u) must be equal to active workers (%u)",
|
||||
ergo_workers, active_workers);
|
||||
|
||||
for(uint i=0; i < active_workers; i++) {
|
||||
q->enqueue(new PSRefProcTaskProxy(task, i));
|
||||
}
|
||||
TaskTerminator terminator(active_workers,
|
||||
(TaskQueueSetSuper*) PSPromotionManager::stack_array_depth());
|
||||
if (task.marks_oops_alive() && active_workers > 1) {
|
||||
for (uint j = 0; j < active_workers; j++) {
|
||||
q->enqueue(new StealTask(terminator.terminator()));
|
||||
}
|
||||
}
|
||||
manager->execute_and_wait(q);
|
||||
void PSRefProcTaskExecutor::execute(ProcessTask& process_task, uint ergo_workers) {
|
||||
PSRefProcTask task(process_task, ergo_workers);
|
||||
ParallelScavengeHeap::heap()->workers().run_task(&task);
|
||||
}
|
||||
|
||||
// This method contains all heap specific policy for invoking scavenge.
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2002, 2019, 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "classfile/systemDictionary.hpp"
|
||||
#include "code/codeCache.hpp"
|
||||
#include "gc/parallel/gcTaskManager.hpp"
|
||||
#include "gc/parallel/parallelScavengeHeap.inline.hpp"
|
||||
#include "gc/parallel/psCardTable.hpp"
|
||||
#include "gc/parallel/psClosure.inline.hpp"
|
||||
#include "gc/parallel/psPromotionManager.hpp"
|
||||
#include "gc/parallel/psPromotionManager.inline.hpp"
|
||||
#include "gc/parallel/psScavenge.inline.hpp"
|
||||
#include "gc/parallel/psTasks.hpp"
|
||||
#include "gc/shared/taskqueue.inline.hpp"
|
||||
#include "memory/iterator.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
#include "oops/oop.inline.hpp"
|
||||
#include "runtime/thread.hpp"
|
||||
#include "runtime/vmThread.hpp"
|
||||
#include "services/management.hpp"
|
||||
|
||||
|
||||
//
|
||||
// StealTask
|
||||
//
|
||||
|
||||
StealTask::StealTask(ParallelTaskTerminator* t) :
|
||||
_terminator(t) {}
|
||||
|
||||
void StealTask::do_it(GCTaskManager* manager, uint which) {
|
||||
assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
|
||||
|
||||
PSPromotionManager* pm =
|
||||
PSPromotionManager::gc_thread_promotion_manager(which);
|
||||
pm->drain_stacks(true);
|
||||
guarantee(pm->stacks_empty(),
|
||||
"stacks should be empty at this point");
|
||||
|
||||
while(true) {
|
||||
StarTask p;
|
||||
if (PSPromotionManager::steal_depth(which, p)) {
|
||||
TASKQUEUE_STATS_ONLY(pm->record_steal(p));
|
||||
pm->process_popped_location_depth(p);
|
||||
pm->drain_stacks_depth(true);
|
||||
} else {
|
||||
if (terminator()->offer_termination()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
guarantee(pm->stacks_empty(), "stacks should be empty at this point");
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2002, 2019, 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SHARE_GC_PARALLEL_PSTASKS_HPP
|
||||
#define SHARE_GC_PARALLEL_PSTASKS_HPP
|
||||
|
||||
#include "utilities/growableArray.hpp"
|
||||
|
||||
//
|
||||
// psTasks.hpp is a collection of GCTasks used by the
|
||||
// parallelScavenge collector.
|
||||
//
|
||||
|
||||
class GCTask;
|
||||
class OopClosure;
|
||||
class OopStack;
|
||||
class ObjectStartArray;
|
||||
class ParallelTaskTerminator;
|
||||
class MutableSpace;
|
||||
class PSOldGen;
|
||||
class Thread;
|
||||
class VMThread;
|
||||
|
||||
//
|
||||
// StealTask
|
||||
//
|
||||
// This task is used to distribute work to idle threads.
|
||||
//
|
||||
|
||||
class StealTask : public GCTask {
|
||||
private:
|
||||
ParallelTaskTerminator* const _terminator;
|
||||
public:
|
||||
char* name() { return (char *)"steal-task"; }
|
||||
|
||||
StealTask(ParallelTaskTerminator* t);
|
||||
|
||||
ParallelTaskTerminator* terminator() { return _terminator; }
|
||||
|
||||
virtual void do_it(GCTaskManager* manager, uint which);
|
||||
};
|
||||
|
||||
#endif // SHARE_GC_PARALLEL_PSTASKS_HPP
|
Loading…
Add table
Add a link
Reference in a new issue