Skip to content

cmd/pprof: unable to generate output file for some formats #16179

@dsnet

Description

@dsnet

Using go1.7beta2

The pprof tools claims:

Output file parameters (for file-based output formats):
-output=f Generate output on file f (stdout by default)

Intuitively, a user would expect a output file to be generated that contains the specified format. However, that is not what always happens. The logic that pprof follows is somewhat convoluted and sometimes it will output the file, sometimes it will still invoke the visualizer, and sometimes it does both, and maybe it does neither in some code paths (it's hard to follow the logic)?

For example, consider the following command:

$ go  tool  pprof  -weblist=.  -output=weblist.html  foo.test  /tmp/cpu.profile
Generating report in weblist.html

One would expect that this outputs the weblist output as the weblist.html file. However, this is not what happens. Running the command invokes the web browser (which fails over SSH). Even worse, it claims to have written the file, when it simply outputs an empty file with nothing in it.

The current logic follows a non-trivial path that is dependent on whether a visualizer is available, whether a post process function is available, and other non-obvious code paths.

Whether the pprof tools outputs a file should be simple:

If there is an output file specified, always write the output to that file. Otherwise, try to invoke the associated visualizer (svg, chrome, stdout, etc...).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions