Commit 1d7c4d91 authored by sanjoy@chromium.org's avatar sanjoy@chromium.org

Track how much time the compiler thread spends doing useful work.

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com/10804027

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12152 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 53f329ab
......@@ -43,13 +43,22 @@ void OptimizingCompilerThread::Run() {
#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;
input_queue_.Dequeue(&optimizing_compiler);
......@@ -60,10 +69,14 @@ void OptimizingCompilerThread::Run() {
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 @@ void OptimizingCompilerThread::Stop() {
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);
}
}
......
......@@ -45,7 +45,9 @@ class OptimizingCompilerThread : public Thread {
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 @@ class OptimizingCompilerThread : public Thread {
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_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment