Revision: 12152
Author: [email protected]
Date: Fri Jul 20 01:56:20 2012
Log: Track how much time the compiler thread spends doing useful work.
BUG=
TEST=
Review URL: https://chromiumcodereview.appspot.com/10804027
http://code.google.com/p/v8/source/detail?r=12152
Modified:
/branches/bleeding_edge/src/optimizing-compiler-thread.cc
/branches/bleeding_edge/src/optimizing-compiler-thread.h
=======================================
--- /branches/bleeding_edge/src/optimizing-compiler-thread.cc Thu Jul 19
11:58:23 2012
+++ /branches/bleeding_edge/src/optimizing-compiler-thread.cc Fri Jul 20
01:56:20 2012
@@ -43,12 +43,21 @@
#endif
Isolate::SetIsolateThreadLocals(isolate_, NULL);
+ int64_t epoch = 0;
+ if (FLAG_trace_parallel_recompilation) epoch = OS::Ticks();
+
while (true) {
input_queue_semaphore_->Wait();
if (Acquire_Load(&stop_thread_)) {
stop_semaphore_->Signal();
+ if (FLAG_trace_parallel_recompilation) {
+ time_spent_total_ = OS::Ticks() - epoch;
+ }
return;
}
+
+ int64_t compiling_start = 0;
+ if (FLAG_trace_parallel_recompilation) compiling_start = OS::Ticks();
Heap::RelocationLock relocation_lock(isolate_->heap());
OptimizingCompiler* optimizing_compiler = NULL;
@@ -60,10 +69,14 @@
OptimizingCompiler::Status status =
optimizing_compiler->OptimizeGraph();
ASSERT(status != OptimizingCompiler::FAILED);
// Prevent an unused-variable error in release mode.
- (void) status;
+ USE(status);
output_queue_.Enqueue(optimizing_compiler);
isolate_->stack_guard()->RequestCodeReadyEvent();
+
+ if (FLAG_trace_parallel_recompilation) {
+ time_spent_compiling_ += OS::Ticks() - compiling_start;
+ }
}
}
@@ -72,6 +85,13 @@
Release_Store(&stop_thread_, static_cast<AtomicWord>(true));
input_queue_semaphore_->Signal();
stop_semaphore_->Wait();
+
+ if (FLAG_trace_parallel_recompilation) {
+ double compile_time = static_cast<double>(time_spent_compiling_);
+ double total_time = static_cast<double>(time_spent_total_);
+ double percentage = (compile_time * 100) / total_time;
+ PrintF(" ** Compiler thread did %.2f%% useful work\n", percentage);
+ }
}
=======================================
--- /branches/bleeding_edge/src/optimizing-compiler-thread.h Thu Jul 19
11:58:23 2012
+++ /branches/bleeding_edge/src/optimizing-compiler-thread.h Fri Jul 20
01:56:20 2012
@@ -45,7 +45,9 @@
Thread("OptimizingCompilerThread"),
isolate_(isolate),
stop_semaphore_(OS::CreateSemaphore(0)),
- input_queue_semaphore_(OS::CreateSemaphore(0)) {
+ input_queue_semaphore_(OS::CreateSemaphore(0)),
+ time_spent_compiling_(0),
+ time_spent_total_(0) {
NoBarrier_Store(&stop_thread_, static_cast<AtomicWord>(false));
NoBarrier_Store(&queue_length_, static_cast<AtomicWord>(0));
}
@@ -86,6 +88,8 @@
UnboundQueue<OptimizingCompiler*> output_queue_;
volatile AtomicWord stop_thread_;
volatile Atomic32 queue_length_;
+ int64_t time_spent_compiling_;
+ int64_t time_spent_total_;
#ifdef DEBUG
int thread_id_;
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev