Sage / streamline-flamegraph

8 stars 0 forks source link

Gzip file seems to be invalid #5

Open aseemk opened 10 years ago

aseemk commented 10 years ago

I'm generating my profile as instructed, I think (and which used to work before the gzip change):

profiler = require 'streamline-flamegraph/lib/record'
# ...
    recorder = profiler.create().start()
    res.on 'finish', ->
        recorder.stop()

When I run the gen-graphs.sh command on the generated perf-recorded.gz:

$ ./node_modules/streamline-flamegraph/bin/gen-graphs.sh 

/path/to/project/node_modules/streamline/lib/callbacks/runtime.js:139
                throw err;
                      ^
TypeError: Cannot call method 'substring' of undefined
    <<< async stack >>>
    at exports_fold__1 (/path/to/project/node_modules/streamline-flamegraph/lib/fold._js:26:36)
    <<< raw stack >>>
    at ___ (/path/to/project/node_modules/streamline-flamegraph/lib/fold._js:26:102)
    at ___ (/path/to/project/node_modules/streamline/lib/callbacks/runtime.js:108:13)
    at Object._onImmediate (/path/to/project/node_modules/streamline-flamegraph/node_modules/ez-streams/lib/devices/uturn._js:26:15)
    at processImmediate [as _immediateCallback] (timers.js:330:15)

ERROR: No stack counts found
ERROR: No stack counts found

It looks like the culprit is that the gzip file is invalid:

$ gunzip perf-recorded.gz 
gunzip: perf-recorded.gz: unexpected end of file
gunzip: perf-recorded.gz: uncompress failed

Running the current/latest version 0.1.4.

bjouhier commented 10 years ago

How do you stop the process? If you call process.exit() just after recorder.stop() the unzip output buffers won't be flushed.

But it could also be a bug. I haven't re-tested recorder.stop() after the change. I'm using ^C with a SIGINT handler in our code.

bjouhier commented 10 years ago

@aseemk I'm suspecting that you are running streamline in callbacks mode. I just fixed a serious bug in the nodify call which is used to zip the data. It may fix your problem: https://github.com/Sage/ez-streams/issues/8

We're running streamline in fibers mode in-house so we don't always catch problems in other modes. Sorry for that.

bjouhier commented 10 years ago

@aseemk I haven't published the ez-streams fix to npm yet. I'll do a bit later in the week-end.