Commit 048b86d6 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Log event start and event end separately when using --log-timer-events.

R=haraken@chromium.org
BUG=

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13529 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 6953861e
...@@ -77,10 +77,13 @@ void* Histogram::CreateHistogram() const { ...@@ -77,10 +77,13 @@ void* Histogram::CreateHistogram() const {
// Start the timer. // Start the timer.
void HistogramTimer::Start() { void HistogramTimer::Start() {
if (histogram_.Enabled() || FLAG_log_internal_timer_events) { if (histogram_.Enabled()) {
stop_time_ = 0; stop_time_ = 0;
start_time_ = OS::Ticks(); start_time_ = OS::Ticks();
} }
if (FLAG_log_internal_timer_events) {
LOG(Isolate::Current(), TimerEvent(Logger::START, histogram_.name_));
}
} }
// Stop the timer and record the results. // Stop the timer and record the results.
...@@ -92,8 +95,7 @@ void HistogramTimer::Stop() { ...@@ -92,8 +95,7 @@ void HistogramTimer::Stop() {
histogram_.AddSample(milliseconds); histogram_.AddSample(milliseconds);
} }
if (FLAG_log_internal_timer_events) { if (FLAG_log_internal_timer_events) {
LOG(Isolate::Current(), LOG(Isolate::Current(), TimerEvent(Logger::END, histogram_.name_));
TimerEvent(histogram_.name_, start_time_, OS::Ticks()));
} }
} }
......
...@@ -633,46 +633,30 @@ void Logger::SharedLibraryEvent(const wchar_t* library_path, ...@@ -633,46 +633,30 @@ void Logger::SharedLibraryEvent(const wchar_t* library_path,
} }
void Logger::TimerEvent(const char* name, int64_t start, int64_t end) { void Logger::TimerEvent(StartEnd se, const char* name) {
if (!log_->IsEnabled()) return; if (!log_->IsEnabled()) return;
ASSERT(FLAG_log_internal_timer_events); ASSERT(FLAG_log_internal_timer_events);
LogMessageBuilder msg(this); LogMessageBuilder msg(this);
int since_epoch = static_cast<int>(start - epoch_); int since_epoch = static_cast<int>(OS::Ticks() - epoch_);
int pause_time = static_cast<int>(end - start); const char* format = (se == START) ? "timer-event-start,\"%s\",%ld\n"
msg.Append("timer-event,\"%s\",%ld,%ld\n", name, since_epoch, pause_time); : "timer-event-end,\"%s\",%ld\n";
msg.Append(format, name, since_epoch);
msg.WriteToLogFile(); msg.WriteToLogFile();
} }
void Logger::ExternalSwitch(StateTag old_tag, StateTag new_tag) {
if (old_tag != EXTERNAL && new_tag == EXTERNAL) {
enter_external_ = OS::Ticks();
}
if (old_tag == EXTERNAL && new_tag != EXTERNAL && enter_external_ != 0) {
TimerEvent("V8.External", enter_external_, OS::Ticks());
enter_external_ = 0;
}
}
void Logger::EnterExternal() { void Logger::EnterExternal() {
LOGGER->enter_external_ = OS::Ticks(); LOG(ISOLATE, TimerEvent(START, TimerEventScope::v8_external));
} }
void Logger::LeaveExternal() { void Logger::LeaveExternal() {
if (enter_external_ == 0) return; LOG(ISOLATE, TimerEvent(END, TimerEventScope::v8_external));
Logger* logger = LOGGER;
logger->TimerEvent("V8.External", enter_external_, OS::Ticks());
logger->enter_external_ = 0;
} }
int64_t Logger::enter_external_ = 0; void Logger::TimerEventScope::LogTimerEvent(StartEnd se) {
LOG(isolate_, TimerEvent(se, name_));
void Logger::TimerEventScope::LogTimerEvent() {
LOG(isolate_, TimerEvent(name_, start_, OS::Ticks()));
} }
...@@ -683,6 +667,7 @@ const char* Logger::TimerEventScope::v8_recompile_parallel = ...@@ -683,6 +667,7 @@ const char* Logger::TimerEventScope::v8_recompile_parallel =
const char* Logger::TimerEventScope::v8_compile_full_code = const char* Logger::TimerEventScope::v8_compile_full_code =
"V8.CompileFullCode"; "V8.CompileFullCode";
const char* Logger::TimerEventScope::v8_execute = "V8.Execute"; const char* Logger::TimerEventScope::v8_execute = "V8.Execute";
const char* Logger::TimerEventScope::v8_external = "V8.External";
void Logger::LogRegExpSource(Handle<JSRegExp> regexp) { void Logger::LogRegExpSource(Handle<JSRegExp> regexp) {
......
...@@ -273,8 +273,9 @@ class Logger { ...@@ -273,8 +273,9 @@ class Logger {
uintptr_t end); uintptr_t end);
// ==== Events logged by --log-timer-events. ==== // ==== Events logged by --log-timer-events. ====
void TimerEvent(const char* name, int64_t start, int64_t end); enum StartEnd { START, END };
void ExternalSwitch(StateTag old_tag, StateTag new_tag);
void TimerEvent(StartEnd se, const char* name);
static void EnterExternal(); static void EnterExternal();
static void LeaveExternal(); static void LeaveExternal();
...@@ -282,25 +283,25 @@ class Logger { ...@@ -282,25 +283,25 @@ class Logger {
class TimerEventScope { class TimerEventScope {
public: public:
TimerEventScope(Isolate* isolate, const char* name) TimerEventScope(Isolate* isolate, const char* name)
: isolate_(isolate), name_(name), start_(0) { : isolate_(isolate), name_(name) {
if (FLAG_log_internal_timer_events) start_ = OS::Ticks(); if (FLAG_log_internal_timer_events) LogTimerEvent(START);
} }
~TimerEventScope() { ~TimerEventScope() {
if (FLAG_log_internal_timer_events) LogTimerEvent(); if (FLAG_log_internal_timer_events) LogTimerEvent(END);
} }
void LogTimerEvent(); void LogTimerEvent(StartEnd se);
static const char* v8_recompile_synchronous; static const char* v8_recompile_synchronous;
static const char* v8_recompile_parallel; static const char* v8_recompile_parallel;
static const char* v8_compile_full_code; static const char* v8_compile_full_code;
static const char* v8_execute; static const char* v8_execute;
static const char* v8_external;
private: private:
Isolate* isolate_; Isolate* isolate_;
const char* name_; const char* name_;
int64_t start_;
}; };
// ==== Events logged by --log-regexp ==== // ==== Events logged by --log-regexp ====
...@@ -473,7 +474,6 @@ class Logger { ...@@ -473,7 +474,6 @@ class Logger {
Address prev_code_; Address prev_code_;
int64_t epoch_; int64_t epoch_;
static int64_t enter_external_;
friend class CpuProfiler; friend class CpuProfiler;
}; };
......
...@@ -67,8 +67,8 @@ VMState::VMState(Isolate* isolate, StateTag tag) ...@@ -67,8 +67,8 @@ VMState::VMState(Isolate* isolate, StateTag tag)
LOG(isolate, UncheckedStringEvent("From", StateToString(previous_tag_))); LOG(isolate, UncheckedStringEvent("From", StateToString(previous_tag_)));
} }
if (FLAG_log_timer_events) { if (FLAG_log_timer_events && previous_tag_ != EXTERNAL && tag == EXTERNAL) {
LOG(isolate, ExternalSwitch(previous_tag_, tag)); LOG(isolate_, EnterExternal());
} }
isolate_->SetCurrentVMState(tag); isolate_->SetCurrentVMState(tag);
...@@ -84,8 +84,9 @@ VMState::~VMState() { ...@@ -84,8 +84,9 @@ VMState::~VMState() {
UncheckedStringEvent("To", StateToString(previous_tag_))); UncheckedStringEvent("To", StateToString(previous_tag_)));
} }
if (FLAG_log_timer_events) { if (FLAG_log_timer_events &&
LOG(isolate_, ExternalSwitch(isolate_->current_vm_state(), previous_tag_)); previous_tag_ != EXTERNAL && isolate_->current_vm_state() == EXTERNAL) {
LOG(isolate_, LeaveExternal());
} }
isolate_->SetCurrentVMState(previous_tag_); isolate_->SetCurrentVMState(previous_tag_);
......
...@@ -41,18 +41,25 @@ else ...@@ -41,18 +41,25 @@ else
$d8_exec --nocrankshaft --prof --logfile $calibration_log \ $d8_exec --nocrankshaft --prof --logfile $calibration_log \
--log-timer-events -e "$calibration_script" > /dev/null --log-timer-events -e "$calibration_script" > /dev/null
t_1=`grep "V8.Execute" $calibration_log | tail -n1 | awk -F, '{print $4}'` t_1_start=`grep "timer-event-start,\"V8.Execute\"" $calibration_log \
n_1=`grep "timer-event" $calibration_log | wc -l` | tail -n1 | awk -F, '{print $3}'`
t_1_end=`grep "timer-event-end,\"V8.Execute\"" $calibration_log \
| tail -n1 | awk -F, '{print $3}'`
n_1=`grep "timer-event\|tick" $calibration_log | wc -l`
$d8_exec --nocrankshaft --prof --logfile $calibration_log \ $d8_exec --nocrankshaft --prof --logfile $calibration_log \
--log-internal-timer-events -e "$calibration_script" > /dev/null --log-internal-timer-events -e "$calibration_script" > /dev/null
t_2=`grep "V8.Execute" $calibration_log | tail -n1 | awk -F, '{print $4}'` t_2_start=`grep "timer-event-start,\"V8.Execute\"" $calibration_log \
n_2=`grep "timer-event" $calibration_log | wc -l` | tail -n1 | awk -F, '{print $3}'`
t_2_end=`grep "timer-event-end,\"V8.Execute\"" $calibration_log \
| tail -n1 | awk -F, '{print $3}'`
n_2=`grep "timer-event\|tick" $calibration_log | wc -l`
rm $calibration_log rm $calibration_log
# Overhead in picoseconds. # Overhead in picoseconds.
distortion=`echo "1000*($t_1 - $t_2)/($n_1 - $n_2)" | bc` distortion=`echo "1000*(($t_1_end - $t_1_start) - ($t_2_end - $t_2_start)) \
/ ($n_1 - $n_2)" | bc`
fi fi
if [ -n "$PLOT_RANGE" ]; then if [ -n "$PLOT_RANGE" ]; then
......
This diff is collapsed.
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