Add option to limit tick processor to a time range.

R=jkummerow@chromium.org
BUG=

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13541 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
yangguo@chromium.org 2013-01-29 14:41:02 +00:00
parent 9cec21e60c
commit c5883d442e
5 changed files with 75 additions and 40 deletions

View File

@ -380,7 +380,10 @@ function driveTickProcessorTest(
separateIc,
TickProcessor.CALL_GRAPH_SIZE,
ignoreUnknown,
stateFilter);
stateFilter,
undefined,
"0",
"auto,auto");
var pm = new PrintMonitor(testsPath + refOutput);
tp.processLogFileInTest(testsPath + logInput);
tp.printStatistics();

View File

@ -32,9 +32,7 @@ if [ ! -x "$d8_exec" ]; then
exit 1
fi
if [ -n "$DISTORTION" ]; then
distortion=$DISTORTION
else
if [[ "$@" != *--distortion* ]]; then
# Try to find out how much the instrumentation overhead is.
calibration_log=calibration.log
calibration_script="for (var i = 0; i < 1000000; i++) print();"
@ -58,21 +56,15 @@ else
rm $calibration_log
# Overhead in picoseconds.
distortion=`echo "1000*(($t_1_end - $t_1_start) - ($t_2_end - $t_2_start)) \
/ ($n_1 - $n_2)" | bc`
options=--distortion=
options+=`echo "1000*(($t_1_end - $t_1_start) - ($t_2_end - $t_2_start)) \
/ ($n_1 - $n_2)" | bc`
echo $options
fi
if [ -n "$PLOT_RANGE" ]; then
plot_range=$PLOT_RANGE
else
plot_range=auto,auto
fi
echo "DISTORTION=$distortion"
echo "PLOT_RANGE=$plot_range"
echo -e "plot-range,$plot_range\ndistortion,$distortion" | cat - $log_file |
$d8_exec $tools_path/csvparser.js \
$tools_path/splaytree.js $tools_path/codemap.js \
$tools_path/logreader.js $tools_path/plot-timer-events.js \
$d8_exec $tools_path/csvparser.js $tools_path/splaytree.js \
$tools_path/codemap.js $tools_path/profile.js $tools_path/profile_view.js \
$tools_path/logreader.js $tools_path/tickprocessor.js \
$tools_path/plot-timer-events.js -- $options $@ | less \
2>/dev/null | gnuplot > timer-events.png

View File

@ -232,17 +232,6 @@ function ProcessTickEvent(pc, sp, timer, unused_x, unused_y, vmstate, stack) {
}
function ProcessDistortion(distortion_in_picoseconds) {
distortion_per_entry = distortion_in_picoseconds / 1000000;
}
function ProcessPlotRange(start, end) {
xrange_start_override = start;
xrange_end_override = end;
}
function FindPlotRange() {
var start_found = (xrange_start_override || xrange_start_override == 0);
var end_found = (xrange_end_override || xrange_end_override == 0);
@ -287,6 +276,26 @@ function parseTimeStamp(timestamp) {
}
function ParseArguments(args) {
var processor = new ArgumentsProcessor(args);
do {
if (!processor.parse()) break;
var result = processor.result();
var distortion = parseInt(result.distortion);
if (isNaN(distortion)) break;
// Convert picoseconds to milliseconds.
distortion_per_entry = distortion / 1000000;
var rangelimits = result.range.split(",");
var range_start = parseInt(rangelimits[0]);
var range_end = parseInt(rangelimits[1]);
xrange_start_override = isNaN(range_start) ? undefined : range_start;
xrange_end_override = isNaN(range_end) ? undefined : range_end;
return;
} while (false);
processor.printUsageAndExit();
}
function CollectData() {
// Collect data from log.
var logreader = new LogReader(
@ -304,11 +313,7 @@ function CollectData() {
processor: ProcessCodeDeleteEvent },
'tick': { parsers: [parseInt, parseInt, parseTimeStamp,
null, null, parseInt, 'var-args'],
processor: ProcessTickEvent },
'distortion': { parsers: [parseInt],
processor: ProcessDistortion },
'plot-range': { parsers: [parseInt, parseInt],
processor: ProcessPlotRange },
processor: ProcessTickEvent }
});
var line;
@ -385,8 +390,6 @@ function RestrictRangesTo(ranges, start, end) {
function GnuplotOutput() {
FindPlotRange();
print("set terminal pngcairo size " + kResX + "," + kResY +
" enhanced font 'Helvetica,10'");
print("set yrange [0:" + (num_timer_event + 1) + "]");
@ -501,5 +504,7 @@ function GnuplotOutput() {
}
ParseArguments(arguments);
CollectData();
FindPlotRange();
GnuplotOutput();

View File

@ -55,6 +55,8 @@ var tickProcessor = new TickProcessor(
params.callGraphSize,
params.ignoreUnknown,
params.stateFilter,
snapshotLogProcessor);
snapshotLogProcessor,
params.distortion,
params.range);
tickProcessor.processLogFile(params.logFileName);
tickProcessor.printStatistics();

View File

@ -151,7 +151,9 @@ function TickProcessor(
callGraphSize,
ignoreUnknown,
stateFilter,
snapshotLogProcessor) {
snapshotLogProcessor,
distortion,
range) {
LogReader.call(this, {
'shared-library': { parsers: [null, parseInt, parseInt],
processor: this.processSharedLibrary },
@ -174,6 +176,10 @@ function TickProcessor(
processor: this.processHeapSampleBegin },
'heap-sample-end': { parsers: [null, null],
processor: this.processHeapSampleEnd },
'timer-event-start' : { parsers: [null, null, null],
processor: this.advanceDistortion },
'timer-event-end' : { parsers: [null, null, null],
processor: this.advanceDistortion },
// Ignored events.
'profiler': null,
'function-creation': null,
@ -194,6 +200,17 @@ function TickProcessor(
var ticks = this.ticks_ =
{ total: 0, unaccounted: 0, excluded: 0, gc: 0 };
distortion = parseInt(distortion);
// Convert picoseconds to nanoseconds.
this.distortion_per_entry = isNaN(distortion) ? 0 : (distortion / 1000);
this.distortion = 0;
var rangelimits = range.split(",");
var range_start = parseInt(rangelimits[0]);
var range_end = parseInt(rangelimits[1]);
// Convert milliseconds to nanoseconds.
this.range_start = isNaN(range_start) ? -Infinity : (range_start * 1000);
this.range_end = isNaN(range_end) ? Infinity : (range_end * 1000)
V8Profile.prototype.handleUnknownCode = function(
operation, addr, opt_stackPos) {
var op = Profile.Operation;
@ -355,6 +372,11 @@ TickProcessor.prototype.processTick = function(pc,
tos_or_external_callback,
vmState,
stack) {
this.distortion += this.distortion_per_entry;
ns_since_start -= this.distortion;
if (ns_since_start < this.range_start || ns_since_start > this.range_end) {
return;
}
this.ticks_.total++;
if (vmState == TickProcessor.VmStates.GC) this.ticks_.gc++;
if (!this.includeTick(vmState)) {
@ -381,6 +403,11 @@ TickProcessor.prototype.processTick = function(pc,
};
TickProcessor.prototype.advanceDistortion = function() {
this.distortion += this.distortion_per_entry;
}
TickProcessor.prototype.processHeapSampleBegin = function(space, state, ticks) {
if (space != 'Heap') return;
this.currentProducerProfile_ = new CallTree();
@ -795,7 +822,11 @@ function ArgumentsProcessor(args) {
'--target': ['targetRootFS', '',
'Specify the target root directory for cross environment'],
'--snapshot-log': ['snapshotLogFileName', 'snapshot.log',
'Specify snapshot log file to use (e.g. --snapshot-log=snapshot.log)']
'Specify snapshot log file to use (e.g. --snapshot-log=snapshot.log)'],
'--range': ['range', 'auto,auto',
'Specify the range limit as [start],[end]'],
'--distortion': ['distortion', 0,
'Specify the logging overhead in picoseconds']
};
this.argsDispatch_['--js'] = this.argsDispatch_['-j'];
this.argsDispatch_['--gc'] = this.argsDispatch_['-g'];
@ -814,7 +845,9 @@ ArgumentsProcessor.DEFAULTS = {
ignoreUnknown: false,
separateIc: false,
targetRootFS: '',
nm: 'nm'
nm: 'nm',
range: 'auto,auto',
distortion: 0
};