Commit 01a423e0 authored by cbruni's avatar cbruni Committed by Commit bot

[--prof] Adding support for RuntimeCallTimerScope based tick separation

BUG=

Review-Url: https://codereview.chromium.org/2050713002
Cr-Commit-Position: refs/heads/master@{#36883}
parent 8c1b2623
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "src/base/platform/platform.h" #include "src/base/platform/platform.h"
#include "src/isolate.h" #include "src/isolate.h"
#include "src/log-inl.h" #include "src/log-inl.h"
#include "src/log.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
......
...@@ -493,6 +493,8 @@ struct RuntimeCallCounter { ...@@ -493,6 +493,8 @@ struct RuntimeCallCounter {
class RuntimeCallTimer { class RuntimeCallTimer {
public: public:
RuntimeCallTimer() {} RuntimeCallTimer() {}
RuntimeCallCounter* counter() { return counter_; }
base::ElapsedTimer timer() { return timer_; }
private: private:
friend class RuntimeCallStats; friend class RuntimeCallStats;
...@@ -775,6 +777,7 @@ class RuntimeCallStats { ...@@ -775,6 +777,7 @@ class RuntimeCallStats {
void Print(std::ostream& os); void Print(std::ostream& os);
RuntimeCallStats() { Reset(); } RuntimeCallStats() { Reset(); }
RuntimeCallTimer* current_timer() { return current_timer_; }
private: private:
// Counter to track recursive time events. // Counter to track recursive time events.
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "src/base/platform/platform.h" #include "src/base/platform/platform.h"
#include "src/bootstrapper.h" #include "src/bootstrapper.h"
#include "src/code-stubs.h" #include "src/code-stubs.h"
#include "src/counters.h"
#include "src/deoptimizer.h" #include "src/deoptimizer.h"
#include "src/global-handles.h" #include "src/global-handles.h"
#include "src/interpreter/bytecodes.h" #include "src/interpreter/bytecodes.h"
...@@ -1421,9 +1422,23 @@ void Logger::DebugEvent(const char* event_type, Vector<uint16_t> parameter) { ...@@ -1421,9 +1422,23 @@ void Logger::DebugEvent(const char* event_type, Vector<uint16_t> parameter) {
msg.WriteToLogFile(); msg.WriteToLogFile();
} }
void Logger::RuntimeCallTimerEvent() {
RuntimeCallStats* stats = isolate_->counters()->runtime_call_stats();
RuntimeCallTimer* timer = stats->current_timer();
if (timer == nullptr) return;
RuntimeCallCounter* counter = timer->counter();
if (counter == nullptr) return;
Log::MessageBuilder msg(log_);
msg.Append("active-runtime-timer,");
msg.AppendDoubleQuotedString(counter->name);
msg.WriteToLogFile();
}
void Logger::TickEvent(TickSample* sample, bool overflow) { void Logger::TickEvent(TickSample* sample, bool overflow) {
if (!log_->IsEnabled() || !FLAG_prof_cpp) return; if (!log_->IsEnabled() || !FLAG_prof_cpp) return;
if (FLAG_runtime_call_stats) {
RuntimeCallTimerEvent();
}
Log::MessageBuilder msg(log_); Log::MessageBuilder msg(log_);
msg.Append("%s,", kLogEventsNames[TICK_EVENT]); msg.Append("%s,", kLogEventsNames[TICK_EVENT]);
msg.AppendAddress(sample->pc); msg.AppendAddress(sample->pc);
......
...@@ -68,6 +68,7 @@ class PositionsRecorder; ...@@ -68,6 +68,7 @@ class PositionsRecorder;
class Profiler; class Profiler;
class Ticker; class Ticker;
struct TickSample; struct TickSample;
class RuntimeCallTimer;
#undef LOG #undef LOG
#define LOG(isolate, Call) \ #define LOG(isolate, Call) \
...@@ -354,6 +355,7 @@ class Logger { ...@@ -354,6 +355,7 @@ class Logger {
// Emits a profiler tick event. Used by the profiler thread. // Emits a profiler tick event. Used by the profiler thread.
void TickEvent(TickSample* sample, bool overflow); void TickEvent(TickSample* sample, bool overflow);
void RuntimeCallTimerEvent();
PRINTF_FORMAT(2, 3) void ApiEvent(const char* format, ...); PRINTF_FORMAT(2, 3) void ApiEvent(const char* format, ...);
......
...@@ -72,6 +72,7 @@ var tickProcessor = new TickProcessor( ...@@ -72,6 +72,7 @@ var tickProcessor = new TickProcessor(
sourceMap, sourceMap,
params.timedRange, params.timedRange,
params.pairwiseTimedRange, params.pairwiseTimedRange,
params.onlySummary); params.onlySummary,
params.runtimeTimerFilter);
tickProcessor.processLogFile(params.logFileName); tickProcessor.processLogFile(params.logFileName);
tickProcessor.printStatistics(); tickProcessor.printStatistics();
...@@ -81,7 +81,8 @@ function TickProcessor( ...@@ -81,7 +81,8 @@ function TickProcessor(
sourceMap, sourceMap,
timedRange, timedRange,
pairwiseTimedRange, pairwiseTimedRange,
onlySummary) { onlySummary,
runtimeTimerFilter) {
LogReader.call(this, { LogReader.call(this, {
'shared-library': { parsers: [null, parseInt, parseInt, parseInt], 'shared-library': { parsers: [null, parseInt, parseInt, parseInt],
processor: this.processSharedLibrary }, processor: this.processSharedLibrary },
...@@ -94,6 +95,9 @@ function TickProcessor( ...@@ -94,6 +95,9 @@ function TickProcessor(
processor: this.processCodeDelete }, processor: this.processCodeDelete },
'sfi-move': { parsers: [parseInt, parseInt], 'sfi-move': { parsers: [parseInt, parseInt],
processor: this.processFunctionMove }, processor: this.processFunctionMove },
'active-runtime-timer': {
parsers: [null],
processor: this.processRuntimeTimerEvent },
'tick': { 'tick': {
parsers: [parseInt, parseInt, parseInt, parsers: [parseInt, parseInt, parseInt,
parseInt, parseInt, 'var-args'], parseInt, parseInt, 'var-args'],
...@@ -124,6 +128,7 @@ function TickProcessor( ...@@ -124,6 +128,7 @@ function TickProcessor(
this.callGraphSize_ = callGraphSize; this.callGraphSize_ = callGraphSize;
this.ignoreUnknown_ = ignoreUnknown; this.ignoreUnknown_ = ignoreUnknown;
this.stateFilter_ = stateFilter; this.stateFilter_ = stateFilter;
this.runtimeTimerFilter_ = runtimeTimerFilter;
this.sourceMap = sourceMap; this.sourceMap = sourceMap;
this.deserializedEntriesNames_ = []; this.deserializedEntriesNames_ = [];
var ticks = this.ticks_ = var ticks = this.ticks_ =
...@@ -284,9 +289,18 @@ TickProcessor.prototype.processFunctionMove = function(from, to) { ...@@ -284,9 +289,18 @@ TickProcessor.prototype.processFunctionMove = function(from, to) {
TickProcessor.prototype.includeTick = function(vmState) { TickProcessor.prototype.includeTick = function(vmState) {
return this.stateFilter_ == null || this.stateFilter_ == vmState; if (this.stateFilter_ !== null) {
return this.stateFilter_ == vmState;
} else if (this.runtimeTimerFilter_ !== null) {
return this.currentRuntimeTimer == this.runtimeTimerFilter_;
}
return true;
}; };
TickProcessor.prototype.processRuntimeTimerEvent = function(name) {
this.currentRuntimeTimer = name;
}
TickProcessor.prototype.processTick = function(pc, TickProcessor.prototype.processTick = function(pc,
ns_since_start, ns_since_start,
is_external_callback, is_external_callback,
...@@ -781,6 +795,8 @@ function ArgumentsProcessor(args) { ...@@ -781,6 +795,8 @@ function ArgumentsProcessor(args) {
'Show only ticks from OTHER VM state'], 'Show only ticks from OTHER VM state'],
'-e': ['stateFilter', TickProcessor.VmStates.EXTERNAL, '-e': ['stateFilter', TickProcessor.VmStates.EXTERNAL,
'Show only ticks from EXTERNAL VM state'], 'Show only ticks from EXTERNAL VM state'],
'--filter-runtime-timer': ['runtimeTimerFilter', null,
'Show only ticks matching the given runtime timer scope'],
'--call-graph-size': ['callGraphSize', TickProcessor.CALL_GRAPH_SIZE, '--call-graph-size': ['callGraphSize', TickProcessor.CALL_GRAPH_SIZE,
'Set the call graph size'], 'Set the call graph size'],
'--ignore-unknown': ['ignoreUnknown', true, '--ignore-unknown': ['ignoreUnknown', true,
...@@ -832,7 +848,8 @@ ArgumentsProcessor.DEFAULTS = { ...@@ -832,7 +848,8 @@ ArgumentsProcessor.DEFAULTS = {
distortion: 0, distortion: 0,
timedRange: false, timedRange: false,
pairwiseTimedRange: false, pairwiseTimedRange: false,
onlySummary: false onlySummary: false,
runtimeTimerFilter: null,
}; };
......
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