Refactor shared logic into CollectedHeap, remove nominal logging and cost->usage
This commit is contained in:
parent
b9a3432f7a
commit
aeb4ad045f
@ -1480,26 +1480,6 @@ void G1CollectedHeap::stop() {
|
||||
_cm_thread->stop();
|
||||
}
|
||||
|
||||
class G1VCPUThreadClosure : public ThreadClosure {
|
||||
private:
|
||||
volatile jlong _vtime = 0;
|
||||
|
||||
public:
|
||||
virtual void do_thread(Thread *thread) {
|
||||
Atomic::add(&_vtime, os::thread_cpu_time(thread));
|
||||
}
|
||||
jlong vtime() { return _vtime; };
|
||||
};
|
||||
|
||||
double G1CollectedHeap::elapsed_gc_vtime() {
|
||||
G1VCPUThreadClosure cl;
|
||||
_cr->threads_do(&cl);
|
||||
_cm->threads_do(&cl);
|
||||
_workers->threads_do(&cl);
|
||||
return ((double) cl.vtime() + os::thread_cpu_time(_service_thread) + os::thread_cpu_time(_cm_thread) + Universe::heap()->vm_vtime()) / NANOSECS_PER_SEC;
|
||||
}
|
||||
|
||||
|
||||
void G1CollectedHeap::safepoint_synchronize_begin() {
|
||||
SuspendibleThreadSet::synchronize();
|
||||
}
|
||||
|
@ -932,8 +932,6 @@ public:
|
||||
GrowableArray<GCMemoryManager*> memory_managers() override;
|
||||
GrowableArray<MemoryPool*> memory_pools() override;
|
||||
|
||||
double elapsed_gc_vtime() override;
|
||||
|
||||
void fill_with_dummy_object(HeapWord* start, HeapWord* end, bool zap) override;
|
||||
|
||||
static void start_codecache_marking_cycle_if_inactive(bool concurrent_mark_start);
|
||||
|
@ -164,23 +164,6 @@ void ParallelScavengeHeap::stop() {
|
||||
log_gc_vtime();
|
||||
}
|
||||
|
||||
class ParallelVCPUThreadClosure : public ThreadClosure {
|
||||
private:
|
||||
volatile jlong _vtime = 0;
|
||||
|
||||
public:
|
||||
virtual void do_thread(Thread *thread) {
|
||||
Atomic::add(&_vtime, os::thread_cpu_time(thread));
|
||||
}
|
||||
jlong vtime() { return _vtime; };
|
||||
};
|
||||
|
||||
double ParallelScavengeHeap::elapsed_gc_vtime() {
|
||||
ParallelVCPUThreadClosure cl;
|
||||
workers().threads_do(&cl);
|
||||
return (double)(cl.vtime() + Universe::heap()->vm_vtime()) / NANOSECS_PER_SEC;
|
||||
}
|
||||
|
||||
void ParallelScavengeHeap::safepoint_synchronize_begin() {
|
||||
if (UseStringDeduplication) {
|
||||
SuspendibleThreadSet::synchronize();
|
||||
|
@ -215,7 +215,6 @@ public:
|
||||
void print_tracing_info() const override;
|
||||
|
||||
void stop() override;
|
||||
double elapsed_gc_vtime() override;
|
||||
|
||||
WorkerThreads* safepoint_workers() override { return &_workers; }
|
||||
|
||||
|
@ -201,6 +201,23 @@ void CollectedHeap::print_relative_to_gc(GCWhen::Type when) const {
|
||||
}
|
||||
}
|
||||
|
||||
class VCPUThreadClosure : public ThreadClosure {
|
||||
private:
|
||||
volatile jlong _vtime = 0;
|
||||
|
||||
public:
|
||||
virtual void do_thread(Thread *thread) {
|
||||
Atomic::add(&_vtime, os::thread_cpu_time(thread));
|
||||
}
|
||||
jlong vtime() { return _vtime; };
|
||||
};
|
||||
|
||||
double CollectedHeap::elapsed_gc_vtime() {
|
||||
VCPUThreadClosure cl;
|
||||
gc_threads_do(&cl);
|
||||
return (double)(cl.vtime() + Universe::heap()->vm_vtime()) / NANOSECS_PER_SEC;
|
||||
}
|
||||
|
||||
void CollectedHeap::print_before_gc() const {
|
||||
print_relative_to_gc(GCWhen::BeforeGC);
|
||||
}
|
||||
@ -221,17 +238,15 @@ void CollectedHeap::log_gc_vtime() {
|
||||
|
||||
if (process_vtime == -1 || gc_vtime == -1) return;
|
||||
|
||||
log_info(gc, cpu)("Process CPU time: %fs", process_vtime);
|
||||
log_info(gc, cpu)("GC CPU time: %fs", gc_vtime);
|
||||
double cost = -1;
|
||||
double usage = -1;
|
||||
if (gc_vtime > process_vtime || process_vtime == 0 || gc_vtime == 0) {
|
||||
// This can happen e.g. for short running processes with
|
||||
// low CPU utilization
|
||||
cost = 0;
|
||||
usage = 0;
|
||||
} else {
|
||||
cost = 100 * gc_vtime / process_vtime;
|
||||
usage = 100 * gc_vtime / process_vtime;
|
||||
}
|
||||
log_info(gc)("GC CPU cost: %2.2f%%", cost);
|
||||
log_info(gc)("GC CPU usage: %2.2f%%", usage);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -465,7 +465,7 @@ protected:
|
||||
// Default implementation does nothing.
|
||||
virtual void print_tracing_info() const = 0;
|
||||
|
||||
virtual double elapsed_gc_vtime() { return -1; };
|
||||
virtual double elapsed_gc_vtime();
|
||||
void log_gc_vtime();
|
||||
|
||||
void print_before_gc() const;
|
||||
|
@ -2220,23 +2220,6 @@ void ShenandoahHeap::stop() {
|
||||
}
|
||||
}
|
||||
|
||||
class ShenandoahCPUThreadClosure : public ThreadClosure {
|
||||
private:
|
||||
volatile jlong _vtime = 0;
|
||||
|
||||
public:
|
||||
virtual void do_thread(Thread *thread) {
|
||||
Atomic::add(&_vtime, os::thread_cpu_time(thread));
|
||||
}
|
||||
jlong vtime() { return _vtime; };
|
||||
};
|
||||
|
||||
double ShenandoahHeap::elapsed_gc_vtime() {
|
||||
ShenandoahCPUThreadClosure cl;
|
||||
ShenandoahHeap::heap()->gc_threads_do(&cl);
|
||||
return (double)(cl.vtime() + Universe::heap()->vm_vtime()) / NANOSECS_PER_SEC;
|
||||
}
|
||||
|
||||
void ShenandoahHeap::stw_unload_classes(bool full_gc) {
|
||||
if (!unload_classes()) return;
|
||||
ClassUnloadingContext ctx(_workers->active_workers(),
|
||||
|
@ -209,8 +209,6 @@ public:
|
||||
|
||||
void stop() override;
|
||||
|
||||
double elapsed_gc_vtime() override;
|
||||
|
||||
void prepare_for_verify() override;
|
||||
void verify(VerifyOption vo) override;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user