Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1229)

Side by Side Diff: src/optimizing-compiler-thread.cc

Issue 10804027: Track how much time the compiler thread spends doing useful work. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/optimizing-compiler-thread.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 25 matching lines...) Expand all
36 namespace v8 { 36 namespace v8 {
37 namespace internal { 37 namespace internal {
38 38
39 39
40 void OptimizingCompilerThread::Run() { 40 void OptimizingCompilerThread::Run() {
41 #ifdef DEBUG 41 #ifdef DEBUG
42 thread_id_ = ThreadId::Current().ToInteger(); 42 thread_id_ = ThreadId::Current().ToInteger();
43 #endif 43 #endif
44 Isolate::SetIsolateThreadLocals(isolate_, NULL); 44 Isolate::SetIsolateThreadLocals(isolate_, NULL);
45 45
46 int64_t epoch = 0;
47 if (FLAG_trace_parallel_recompilation) epoch = OS::Ticks();
48
46 while (true) { 49 while (true) {
47 input_queue_semaphore_->Wait(); 50 input_queue_semaphore_->Wait();
48 if (Acquire_Load(&stop_thread_)) { 51 if (Acquire_Load(&stop_thread_)) {
49 stop_semaphore_->Signal(); 52 stop_semaphore_->Signal();
53 if (FLAG_trace_parallel_recompilation) {
54 time_spent_total_ = OS::Ticks() - epoch;
55 }
50 return; 56 return;
51 } 57 }
52 58
59 int64_t compiling_start = 0;
60 if (FLAG_trace_parallel_recompilation) compiling_start = OS::Ticks();
61
53 Heap::RelocationLock relocation_lock(isolate_->heap()); 62 Heap::RelocationLock relocation_lock(isolate_->heap());
54 OptimizingCompiler* optimizing_compiler = NULL; 63 OptimizingCompiler* optimizing_compiler = NULL;
55 input_queue_.Dequeue(&optimizing_compiler); 64 input_queue_.Dequeue(&optimizing_compiler);
56 Barrier_AtomicIncrement(&queue_length_, static_cast<Atomic32>(-1)); 65 Barrier_AtomicIncrement(&queue_length_, static_cast<Atomic32>(-1));
57 66
58 ASSERT(!optimizing_compiler->info()->closure()->IsOptimized()); 67 ASSERT(!optimizing_compiler->info()->closure()->IsOptimized());
59 68
60 OptimizingCompiler::Status status = optimizing_compiler->OptimizeGraph(); 69 OptimizingCompiler::Status status = optimizing_compiler->OptimizeGraph();
61 ASSERT(status != OptimizingCompiler::FAILED); 70 ASSERT(status != OptimizingCompiler::FAILED);
62 // Prevent an unused-variable error in release mode. 71 // Prevent an unused-variable error in release mode.
63 (void) status; 72 (void) status;
Yang 2012/07/20 08:21:38 Change this to USE(status)
64 73
65 output_queue_.Enqueue(optimizing_compiler); 74 output_queue_.Enqueue(optimizing_compiler);
66 isolate_->stack_guard()->RequestCodeReadyEvent(); 75 isolate_->stack_guard()->RequestCodeReadyEvent();
76
77 if (FLAG_trace_parallel_recompilation) {
78 time_spent_compiling_ += OS::Ticks() - compiling_start;
79 }
67 } 80 }
68 } 81 }
69 82
70 83
71 void OptimizingCompilerThread::Stop() { 84 void OptimizingCompilerThread::Stop() {
72 Release_Store(&stop_thread_, static_cast<AtomicWord>(true)); 85 Release_Store(&stop_thread_, static_cast<AtomicWord>(true));
73 input_queue_semaphore_->Signal(); 86 input_queue_semaphore_->Signal();
74 stop_semaphore_->Wait(); 87 stop_semaphore_->Wait();
88
89 if (FLAG_trace_parallel_recompilation) {
90 double compile_time = static_cast<double>(time_spent_compiling_);
91 double total_time = static_cast<double>(time_spent_total_);
92 double percentage = (compile_time * 100) / total_time;
93 PrintF(" ** Compiler thread did %.2f%% useful work\n", percentage);
94 }
75 } 95 }
76 96
77 97
78 void OptimizingCompilerThread::InstallOptimizedFunctions() { 98 void OptimizingCompilerThread::InstallOptimizedFunctions() {
79 HandleScope handle_scope(isolate_); 99 HandleScope handle_scope(isolate_);
80 int functions_installed = 0; 100 int functions_installed = 0;
81 while (!output_queue_.IsEmpty()) { 101 while (!output_queue_.IsEmpty()) {
82 OptimizingCompiler* compiler = NULL; 102 OptimizingCompiler* compiler = NULL;
83 output_queue_.Dequeue(&compiler); 103 output_queue_.Dequeue(&compiler);
84 Compiler::InstallOptimizedCode(compiler); 104 Compiler::InstallOptimizedCode(compiler);
(...skipping 13 matching lines...) Expand all
98 118
99 #ifdef DEBUG 119 #ifdef DEBUG
100 bool OptimizingCompilerThread::IsOptimizerThread() { 120 bool OptimizingCompilerThread::IsOptimizerThread() {
101 if (!FLAG_parallel_recompilation) return false; 121 if (!FLAG_parallel_recompilation) return false;
102 return ThreadId::Current().ToInteger() == thread_id_; 122 return ThreadId::Current().ToInteger() == thread_id_;
103 } 123 }
104 #endif 124 #endif
105 125
106 126
107 } } // namespace v8::internal 127 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/optimizing-compiler-thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698