Skip to content

cmd/pprof: weblist is unusable on Go1.7 #16154

@dsnet

Description

@dsnet

Using 4764d6f

Using the weblist command in pprof now generates an unreasonably large html file. In Go1.6 this generates a 209KB html file, while HEAD generates a 450MB html file for even a simple benchmark. On larger benchmarks (which are far more common), this crashes the system by using up all system memory.

Current behavior:

$ go.dev test -c foo_test.go
$ ./foo.test -test.bench . -test.cpuprofile /tmp/cpu.out
$ go.dev tool pprof ./foo.test /tmp/cpu.out
(pprof) weblist # Stalls for several seconds... the output html file is 450MB

Wanted behavior:

$ go1.6 test -c foo_test.go
$ ./foo.test -test.bench . -test.cpuprofile /tmp/cpu.out
$ go1.6 tool pprof ./foo.test /tmp/cpu.out
(pprof) weblist # Immediately launches browser with html file that is 209KB

Contents of foo_test.go (could be anything):

package foo

import (
    "bufio"
    "io"
    "strings"
    "testing"
)

func BenchmarkFoo(b *testing.B) {
    s := strings.Repeat("Hello, world!", 100000)

    b.SetBytes(int64(len(s)))
    for i := 0; i < b.N; i++ {
        var r io.ByteReader
        r = bufio.NewReader(strings.NewReader(s))
        for {
            _, err := r.ReadByte()
            if err != nil {
                if err == io.EOF {
                    break
                }
                b.Fatal(err)
            }
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions