question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Rishabh570commented, Aug 7, 2020

I used 8.12 but now i have an error:

/bin/sh: 1: ’autocannon: not found Fatal error in process observed by 0x. Incomplete V8 isolate log deleted. To preserve these logs, enable debugging (e.g. DEBUG=0x* 0x my-app.js)

But i can execute autocannon commands

I also got this exact error but this was just because of the quote being messed up during copy-paste.

1reaction
BridgeARcommented, Oct 16, 2018

Runs fine on 10 and throws an error on 8.12.0 for me:

bufferAnalysing data
/home/ruben/.nvm/versions/node/v8.12.0/lib/node_modules/clinic/bin.js:261
        if (err) throw err
                 ^

TypeError: "file" argument must be a non-empty string
    at normalizeSpawnArguments (child_process.js:384:11)
    at spawnSync (child_process.js:520:38)
    at ticksToTree (/home/ruben/.nvm/versions/node/v8.12.0/lib/node_modules/clinic/node_modules/0x/lib/ticks-to-tree.js:30:21)
    at render (/home/ruben/.nvm/versions/node/v8.12.0/lib/node_modules/clinic/node_modules/0x/lib/render.js:19:17)
    at generateFlamegraph (/home/ruben/.nvm/versions/node/v8.12.0/lib/node_modules/clinic/node_modules/0x/index.js:76:22)
    at visualize (/home/ruben/.nvm/versions/node/v8.12.0/lib/node_modules/clinic/node_modules/0x/index.js:119:24)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)

I’ll have a closer look at 8 and why we run into an issue there.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found