Revision: 3811
Author: [email protected]
Date: Mon Feb 8 00:15:18 2010
Log: Profiler tick processor: exploit d8's readline to avoid reading
entire file prior to parsing it. This allows processing of huge
log files (over 200 MB.)
Review URL: http://codereview.chromium.org/574015
http://code.google.com/p/v8/source/detail?r=3811
Modified:
/branches/bleeding_edge/tools/linux-tick-processor
/branches/bleeding_edge/tools/logreader.js
/branches/bleeding_edge/tools/tickprocessor.js
/branches/bleeding_edge/tools/windows-tick-processor.bat
=======================================
--- /branches/bleeding_edge/tools/linux-tick-processor Wed Jul 8 23:39:38
2009
+++ /branches/bleeding_edge/tools/linux-tick-processor Mon Feb 8 00:15:18
2010
@@ -16,8 +16,17 @@
[ -x $d8_exec ] || scons -j4 -C $D8_PATH -Y $tools_path/.. d8
fi
+# find the name of the log file to process, it must not start with a dash.
+log_file="v8.log"
+for arg in "$@"
+do
+ if [[ "${arg}" != -* ]]; then
+ log_file=${arg}
+ fi
+done
+
# nm spits out 'no symbols found' messages to stderr.
-$d8_exec $tools_path/splaytree.js $tools_path/codemap.js \
+cat $log_file | $d8_exec $tools_path/splaytree.js $tools_path/codemap.js \
$tools_path/csvparser.js $tools_path/consarray.js \
$tools_path/profile.js $tools_path/profile_view.js \
$tools_path/logreader.js $tools_path/tickprocessor.js \
=======================================
--- /branches/bleeding_edge/tools/logreader.js Thu Jan 21 08:42:41 2010
+++ /branches/bleeding_edge/tools/logreader.js Mon Feb 8 00:15:18 2010
@@ -76,6 +76,18 @@
* @type {Array.<string>}
*/
this.backRefs_ = [];
+
+ /**
+ * Current line.
+ * @type {number}
+ */
+ this.lineNum_ = 0;
+
+ /**
+ * CSV lines parser.
+ * @type {devtools.profiler.CsvParser}
+ */
+ this.csvParser_ = new devtools.profiler.CsvParser();
};
@@ -135,6 +147,16 @@
};
+/**
+ * Processes a line of V8 profiler event log.
+ *
+ * @param {string} line A line of log.
+ */
+devtools.profiler.LogReader.prototype.processLogLine = function(line) {
+ this.processLog_([line]);
+};
+
+
/**
* Processes stack record.
*
@@ -280,25 +302,20 @@
* @private
*/
devtools.profiler.LogReader.prototype.processLog_ = function(lines) {
- var csvParser = new devtools.profiler.CsvParser();
- try {
- for (var i = 0, n = lines.length; i < n; ++i) {
- var line = lines[i];
- if (!line) {
- continue;
- }
+ for (var i = 0, n = lines.length; i < n; ++i, ++this.lineNum_) {
+ var line = lines[i];
+ if (!line) {
+ continue;
+ }
+ try {
if (line.charAt(0) == '#' ||
line.substr(0, line.indexOf(',')) in this.backRefsCommands_) {
line = this.expandBackRef_(line);
}
- var fields = csvParser.parseLine(line);
+ var fields = this.csvParser_.parseLine(line);
this.dispatchLogRow_(fields);
- }
- } catch (e) {
- // An error on the last line is acceptable since log file can be
truncated.
- if (i < n - 1) {
- this.printError('line ' + (i + 1) + ': ' + (e.message || e));
- throw e;
+ } catch (e) {
+ this.printError('line ' + (this.lineNum_ + 1) + ': ' + (e.message ||
e));
}
}
};
=======================================
--- /branches/bleeding_edge/tools/tickprocessor.js Thu Feb 4 13:34:03 2010
+++ /branches/bleeding_edge/tools/tickprocessor.js Mon Feb 8 00:15:18 2010
@@ -262,8 +262,10 @@
TickProcessor.prototype.processLogFile = function(fileName) {
this.lastLogFileName_ = fileName;
- var contents = readFile(fileName);
- this.processLogChunk(contents);
+ var line;
+ while (line = readline()) {
+ this.processLogLine(line);
+ }
};
=======================================
--- /branches/bleeding_edge/tools/windows-tick-processor.bat Wed Jul 8
23:39:38 2009
+++ /branches/bleeding_edge/tools/windows-tick-processor.bat Mon Feb 8
00:15:18 2010
@@ -2,4 +2,28 @@
SET tools_dir=%~dp0
-%tools_dir%..\d8 %tools_dir%splaytree.js %tools_dir%codemap.js %tools_dir%csvparser.js %tools_dir%consarray.js %tools_dir%profile.js %tools_dir%profile_view.js %tools_dir%logreader.js %tools_dir%tickprocessor.js %tools_dir%tickprocessor-driver.js
--
--windows %*
+SET log_file=v8.log
+
+rem find the name of the log file to process, it must not start with a
dash.
+rem we prepend cmdline args with a number (in fact, any letter or number)
+rem to cope with empty arguments.
+SET arg1=1%1
+IF NOT %arg1:~0,2% == 1 (IF NOT %arg1:~0,2% == 1- SET log_file=%1)
+SET arg2=2%2
+IF NOT %arg2:~0,2% == 2 (IF NOT %arg2:~0,2% == 2- SET log_file=%2)
+SET arg3=3%3
+IF NOT %arg3:~0,2% == 3 (IF NOT %arg3:~0,2% == 3- SET log_file=%3)
+SET arg4=4%4
+IF NOT %arg4:~0,2% == 4 (IF NOT %arg4:~0,2% == 4- SET log_file=%4)
+SET arg5=5%5
+IF NOT %arg5:~0,2% == 5 (IF NOT %arg5:~0,2% == 5- SET log_file=%5)
+SET arg6=6%6
+IF NOT %arg6:~0,2% == 6 (IF NOT %arg6:~0,2% == 6- SET log_file=%6)
+SET arg7=7%7
+IF NOT %arg7:~0,2% == 7 (IF NOT %arg7:~0,2% == 7- SET log_file=%7)
+SET arg8=8%8
+IF NOT %arg8:~0,2% == 8 (IF NOT %arg8:~0,2% == 8- SET log_file=%8)
+SET arg9=9%9
+IF NOT %arg9:~0,2% == 9 (IF NOT %arg9:~0,2% == 9- SET log_file=%9)
+
+type %log_file%
| %tools_dir%..\d8 %tools_dir%splaytree.js %tools_dir%codemap.js %tools_dir%csvparser.js %tools_dir%consarray.js %tools_dir%profile.js %tools_dir%profile_view.js %tools_dir%logreader.js %tools_dir%tickprocessor.js %tools_dir%tickprocessor-driver.js
-- --windows %*
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev