Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8256813: Simplify WeakProcessor counting of OopStorage entries #1362

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -65,9 +65,9 @@ void WeakProcessor::weak_oops_do(BoolObjectClosure* is_alive, OopClosure* keep_a
OopStorageSet::Iterator it = OopStorageSet::weak_iterator();
for ( ; !it.is_end(); ++it) {
if (it->should_report_num_dead()) {
CountingSkippedIsAliveClosure<BoolObjectClosure, OopClosure> cl(is_alive, keep_alive);
CountingClosure<BoolObjectClosure, OopClosure> cl(is_alive, keep_alive);
it->oops_do(&cl);
it->report_num_dead(cl.num_skipped() + cl.num_dead());
it->report_num_dead(cl.dead());
} else {
it->weak_oops_do(is_alive, keep_alive);
}
@@ -91,12 +91,6 @@ uint WeakProcessor::ergo_workers(uint max_workers) {

// One thread per ReferencesPerThread references (or fraction thereof)
// in the various OopStorage objects, bounded by max_threads.
//
// Serial phases are ignored in this calculation, because of the
// cost of running unnecessary threads. These phases are normally
// small or empty (assuming they are configured to exist at all),
// and development oriented, so not allocating any threads
// specifically for them is okay.
size_t ref_count = 0;
OopStorageSet::Iterator it = OopStorageSet::weak_iterator();
for ( ; !it.is_end(); ++it) {
@@ -71,6 +71,9 @@ class WeakProcessor : AllStatic {
class Task;

private:
template<typename IsAlive, typename KeepAlive>
class CountingClosure;

class GangTask;
};

@@ -38,52 +38,39 @@
class BoolObjectClosure;
class OopClosure;

template<typename IsAlive>
class CountingIsAliveClosure : public BoolObjectClosure {
IsAlive* _inner;

size_t _num_dead;
size_t _num_total;

public:
CountingIsAliveClosure(IsAlive* cl) : _inner(cl), _num_dead(0), _num_total(0) { }

virtual bool do_object_b(oop obj) {
bool result = _inner->do_object_b(obj);
_num_dead += !result;
_num_total++;
return result;
}

size_t num_dead() const { return _num_dead; }
size_t num_total() const { return _num_total; }
};

template <typename IsAlive, typename KeepAlive>
class CountingSkippedIsAliveClosure : public Closure {
CountingIsAliveClosure<IsAlive> _counting_is_alive;
class WeakProcessor::CountingClosure : public Closure {
IsAlive* _is_alive;
KeepAlive* _keep_alive;

size_t _num_skipped;
size_t _old_dead;
size_t _new_dead;
size_t _live;

public:
CountingSkippedIsAliveClosure(IsAlive* is_alive, KeepAlive* keep_alive) :
_counting_is_alive(is_alive), _keep_alive(keep_alive), _num_skipped(0) { }
CountingClosure(IsAlive* is_alive, KeepAlive* keep_alive) :
_is_alive(is_alive),
_keep_alive(keep_alive),
_old_dead(0),
_new_dead(0),
_live(0)
{}

void do_oop(oop* p) {
oop obj = *p;
if (obj == NULL) {
_num_skipped++;
} else if (_counting_is_alive.do_object_b(obj)) {
++_old_dead;
} else if (_is_alive->do_object_b(obj)) {
_keep_alive->do_oop(p);
++_live;
} else {
*p = NULL;
++_new_dead;
}
}

size_t num_dead() const { return _counting_is_alive.num_dead(); }
size_t num_skipped() const { return _num_skipped; }
size_t num_total() const { return _counting_is_alive.num_total() + num_skipped(); }
size_t dead() const { return _old_dead + _new_dead; }
size_t new_dead() const { return _new_dead; }
size_t total() const { return dead() + _live; }
};

template<typename IsAlive, typename KeepAlive>
@@ -98,13 +85,13 @@ void WeakProcessor::Task::work(uint worker_id,

for (Iterator it = WeakProcessorPhases::oopstorage_iterator(); !it.is_end(); ++it) {
WeakProcessorPhase phase = *it;
CountingSkippedIsAliveClosure<IsAlive, KeepAlive> cl(is_alive, keep_alive);
CountingClosure<IsAlive, KeepAlive> cl(is_alive, keep_alive);
WeakProcessorPhaseTimeTracker pt(_phase_times, phase, worker_id);
StorageState* cur_state = _storage_states.par_state(phase);
cur_state->oops_do(&cl);
cur_state->increment_num_dead(cl.num_skipped() + cl.num_dead());
cur_state->increment_num_dead(cl.dead());
if (_phase_times != NULL) {
_phase_times->record_worker_items(worker_id, phase, cl.num_dead(), cl.num_total());
_phase_times->record_worker_items(worker_id, phase, cl.new_dead(), cl.total());
}
}
}