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

Side by Side Diff: src/log.cc

Issue 113961: Two simple profiler changes: 1) log sampling rate, 2) check current state before pausing & resuming. (Closed)
Patch Set: Created 11 years, 6 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
« no previous file with comments | « src/log.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 void Profiler::Engage() { 249 void Profiler::Engage() {
250 OS::LogSharedLibraryAddresses(); 250 OS::LogSharedLibraryAddresses();
251 251
252 // Start thread processing the profiler buffer. 252 // Start thread processing the profiler buffer.
253 running_ = true; 253 running_ = true;
254 Start(); 254 Start();
255 255
256 // Register to get ticks. 256 // Register to get ticks.
257 Logger::ticker_->SetProfiler(this); 257 Logger::ticker_->SetProfiler(this);
258 258
259 LOG(UncheckedStringEvent("profiler", "begin")); 259 Logger::ProfilerBeginEvent();
260 } 260 }
261 261
262 262
263 void Profiler::Disengage() { 263 void Profiler::Disengage() {
264 // Stop receiving ticks. 264 // Stop receiving ticks.
265 Logger::ticker_->ClearProfiler(); 265 Logger::ticker_->ClearProfiler();
266 266
267 // Terminate the worker thread by setting running_ to false, 267 // Terminate the worker thread by setting running_ to false,
268 // inserting a fake element in the queue and then wait for 268 // inserting a fake element in the queue and then wait for
269 // the thread to terminate. 269 // the thread to terminate.
(...skipping 25 matching lines...) Expand all
295 Profiler* Logger::profiler_ = NULL; 295 Profiler* Logger::profiler_ = NULL;
296 VMState* Logger::current_state_ = NULL; 296 VMState* Logger::current_state_ = NULL;
297 VMState Logger::bottom_state_(EXTERNAL); 297 VMState Logger::bottom_state_(EXTERNAL);
298 SlidingStateWindow* Logger::sliding_state_window_ = NULL; 298 SlidingStateWindow* Logger::sliding_state_window_ = NULL;
299 299
300 300
301 bool Logger::IsEnabled() { 301 bool Logger::IsEnabled() {
302 return Log::IsEnabled(); 302 return Log::IsEnabled();
303 } 303 }
304 304
305
306 void Logger::ProfilerBeginEvent() {
307 if (!Log::IsEnabled()) return;
308 LogMessageBuilder msg;
309 msg.Append("profiler,\"begin\",%d\n", kSamplingIntervalMs);
310 msg.WriteToLogFile();
311 }
312
305 #endif // ENABLE_LOGGING_AND_PROFILING 313 #endif // ENABLE_LOGGING_AND_PROFILING
306 314
307 315
308 void Logger::Preamble(const char* content) { 316 void Logger::Preamble(const char* content) {
309 #ifdef ENABLE_LOGGING_AND_PROFILING 317 #ifdef ENABLE_LOGGING_AND_PROFILING
310 if (!Log::IsEnabled() || !FLAG_log_code) return; 318 if (!Log::IsEnabled() || !FLAG_log_code) return;
311 LogMessageBuilder msg; 319 LogMessageBuilder msg;
312 msg.WriteCStringToLogFile(content); 320 msg.WriteCStringToLogFile(content);
313 #endif 321 #endif
314 } 322 }
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 msg.WriteToLogFile(); 810 msg.WriteToLogFile();
803 } 811 }
804 812
805 813
806 bool Logger::IsProfilerPaused() { 814 bool Logger::IsProfilerPaused() {
807 return profiler_->paused(); 815 return profiler_->paused();
808 } 816 }
809 817
810 818
811 void Logger::PauseProfiler() { 819 void Logger::PauseProfiler() {
820 if (profiler_->paused()) {
821 return;
822 }
812 profiler_->pause(); 823 profiler_->pause();
813 if (FLAG_prof_lazy) { 824 if (FLAG_prof_lazy) {
814 if (!FLAG_sliding_state_window) ticker_->Stop(); 825 if (!FLAG_sliding_state_window) ticker_->Stop();
815 FLAG_log_code = false; 826 FLAG_log_code = false;
816 // Must be the same message as Log::kDynamicBufferSeal. 827 // Must be the same message as Log::kDynamicBufferSeal.
817 LOG(UncheckedStringEvent("profiler", "pause")); 828 LOG(UncheckedStringEvent("profiler", "pause"));
818 } 829 }
819 } 830 }
820 831
821 832
822 void Logger::ResumeProfiler() { 833 void Logger::ResumeProfiler() {
823 if (!Log::IsEnabled()) return; 834 if (!profiler_->paused() || !Log::IsEnabled()) {
835 return;
836 }
824 if (FLAG_prof_lazy) { 837 if (FLAG_prof_lazy) {
825 LOG(UncheckedStringEvent("profiler", "resume")); 838 LOG(UncheckedStringEvent("profiler", "resume"));
826 FLAG_log_code = true; 839 FLAG_log_code = true;
827 LogCompiledFunctions(); 840 LogCompiledFunctions();
828 if (!FLAG_sliding_state_window) ticker_->Start(); 841 if (!FLAG_sliding_state_window) ticker_->Start();
829 } 842 }
830 profiler_->resume(); 843 profiler_->resume();
831 } 844 }
832 845
833 846
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 } else { 998 } else {
986 Log::OpenFile(FLAG_logfile); 999 Log::OpenFile(FLAG_logfile);
987 } 1000 }
988 } 1001 }
989 1002
990 current_state_ = &bottom_state_; 1003 current_state_ = &bottom_state_;
991 1004
992 // as log is initialized early with V8, we can assume that JS execution 1005 // as log is initialized early with V8, we can assume that JS execution
993 // frames can never reach this point on stack 1006 // frames can never reach this point on stack
994 int stack_var; 1007 int stack_var;
995 ticker_ = new Ticker(1, reinterpret_cast<uintptr_t>(&stack_var)); 1008 ticker_ = new Ticker(
1009 kSamplingIntervalMs, reinterpret_cast<uintptr_t>(&stack_var));
996 1010
997 if (FLAG_sliding_state_window && sliding_state_window_ == NULL) { 1011 if (FLAG_sliding_state_window && sliding_state_window_ == NULL) {
998 sliding_state_window_ = new SlidingStateWindow(); 1012 sliding_state_window_ = new SlidingStateWindow();
999 } 1013 }
1000 1014
1001 if (FLAG_prof) { 1015 if (FLAG_prof) {
1002 profiler_ = new Profiler(); 1016 profiler_ = new Profiler();
1003 if (!FLAG_prof_auto) 1017 if (!FLAG_prof_auto)
1004 profiler_->pause(); 1018 profiler_->pause();
1005 profiler_->Engage(); 1019 profiler_->Engage();
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 } else if (previous_->state_ == EXTERNAL) { 1145 } else if (previous_->state_ == EXTERNAL) {
1132 // We are leaving V8. 1146 // We are leaving V8.
1133 Heap::Protect(); 1147 Heap::Protect();
1134 } 1148 }
1135 } 1149 }
1136 #endif 1150 #endif
1137 } 1151 }
1138 #endif 1152 #endif
1139 1153
1140 } } // namespace v8::internal 1154 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/log.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698