Flame graph not works on linux
See original GitHub issue- Execute: clinic flame --on-port=’autocannon -c2 localhost:$PORT/seed/v1’ – node index.js
- After 2 minutes i press CTRL + C
- Console export: -
- Export: isolate file.log
where is the html file ?
Node: 8.9 OS: ubuntu 16.04
Index.js
` ‘use strict’
const restify = require('restify')
const { etagger, timestamp, fetchContent } = require('./util')()
const server = restify.createServer()
server.use(etagger().bind(server))
server.get('/seed/v1', function (req, res, next) {
fetchContent(req.url, (err, content) => {
if (err) return next(err)
res.send({data: content, url: req.url, ts: timestamp()})
next()
})
})
server.listen(3000)`
util.js ` “use strict”;
require(“events”).defaultMaxListeners = Infinity; const crypto = require(“crypto”);
module.exports = () => { const content = crypto.rng(5000).toString(“hex”); const ONE_MINUTE = 60000; var last = Date.now();
function timestamp() {
var now = Date.now();
if (now - last >= ONE_MINUTE) last = now;
return last;
}
function etagger() {
var cache = {};
var afterEventAttached = false;
function attachAfterEvent(server) {
if (attachAfterEvent === true) return;
afterEventAttached = true;
server.on("after", (req, res) => {
if (res.statusCode !== 200) return;
if (!res._body) return;
const key = crypto
.createHash("sha512")
.update(req.url)
.digest()
.toString("hex");
const etag = crypto
.createHash("sha512")
.update(JSON.stringify(res._body))
.digest()
.toString("hex");
if (cache[key] !== etag) cache[key] = etag;
});
}
return function(req, res, next) {
attachAfterEvent(this);
const key = crypto
.createHash("sha512")
.update(req.url)
.digest()
.toString("hex");
if (key in cache) res.set("Etag", cache[key]);
res.set("Cache-Control", "public, max-age=120");
next();
};
}
function fetchContent(url, cb) {
setImmediate(() => {
if (url !== "/seed/v1")
cb(Object.assign(Error("Not Found"), { statusCode: 404 }));
else cb(null, content);
});
}
return { timestamp, etagger, fetchContent };
};
`
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Flame graph not works on linux · Issue #65 · clinicjs/node-clinic
Execute: clinic flame --on-port='autocannon -c2 localhost:$PORT/seed/v1' -- node index.js After 2 minutes i press CTRL + C Console export: ...
Read more >CPU Flame Graphs - Brendan Gregg
Flame Graphs can work with any CPU profiler on any operating system. My examples here use Linux perf (perf_events), DTrace, SystemTap, and ktap....
Read more >dtrace and linux perf tools not working in ubuntu
but not sure how I can run that command using PID for the node app I am running. Is there any other way...
Read more >The Flame Graph - ACM Queue
Linux perf_events can condense profiler output even further: not only identical stack trace samples, but also subsets of stack traces can be ...
Read more >Chapter 27. Getting started with flamegraphs
# perf script flamegraph -a -F 99 sleep 60. This command samples and records performance data over the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I also got this exact error but this was just because of the quote being messed up during copy-paste.
Runs fine on 10 and throws an error on 8.12.0 for me:
I’ll have a closer look at 8 and why we run into an issue there.