Skip to content

Instantly share code, notes, and snippets.

@alessioalex alessioalex/convert.js

forked from rf/convert.js
Last active Aug 29, 2015
What would you like to do?
var fs = require('fs');
var infile = process.argv[2];
if (!infile) return console.log("need infile");
var data = fs.readFileSync(infile, 'utf8').split('\n');
var outlines = [];
data.forEach(function(item) {
var parts = item.split(',');
if (parts.length < 5) return;
if (parts[0] != 'code-creation') return;
var length = parseInt(parts[3], 10).toString(16);
var type = parts[1];
var start = parts[2].slice(2);
var name = parts[4].slice(1, -1);
outlines.push(start + " " + length + " " + type + ":" + name);

Use the v8 log to symbolicate linux perf output without having to upgrade yo node. This works with node v0.10. v0.11 has a slightly different v8 log file format so it won't quite work but a similar technique would work.

Run node like this

$ node --logfile="/tmp/node-%p.log" --nocompact_code_space --log_code program.js

Get some perf samples

$ perf record -e cycles:u -g -p $PID

Then convert the v8 log file to a perf map

$ node convert.js /tmp/node-$PID.log > /tmp/perf-$

Extract trace from file

$ perf script > perf-script.txt

And make a flame graph

cat perf-script.txt | flamegraph --inputtype perf > perf-graph.svg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.