Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/pprof: make runtime.reflectcall followable by pprof #11786

Open
thwd opened this issue Jul 19, 2015 · 4 comments
Open

cmd/pprof: make runtime.reflectcall followable by pprof #11786

thwd opened this issue Jul 19, 2015 · 4 comments
Milestone

Comments

@thwd
Copy link

thwd commented Jul 19, 2015

Context: http://stackoverflow.com/q/31419307/532430

Proposal: allow pprof to follow reflective function invocations via runtime.reflectcall so that code "after the jump" can be profiled.

I think the idea is simple enough but if anything was unclear just ask and I'll try to clarify.

@ianlancetaylor
Copy link
Contributor

To be honest, I'm not sure this has to be a proposal. I think the current behaviour is a bug. I don't know what is involved in fixing it, but I can't imagine that anybody would object to a good fix.

@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Jul 20, 2015
@adg adg changed the title proposal: make runtime.reflectcall followable by pprof runtime: make runtime.reflectcall followable by pprof Aug 24, 2015
@adg adg removed the Proposal label Aug 24, 2015
@adg
Copy link
Contributor

adg commented Aug 24, 2015

Agree, this needn't be a proposal.

@rsc
Copy link
Contributor

rsc commented Nov 5, 2015

This is a bug in pprof alone. The full information is in the profile, but the elision of runtime frames is getting confused by the reflect call and eliding everything below it. You can see the extra information using -runtime.

$ cat x_test.go
package x

import (
    "reflect"
    "testing"
)

func TestReflect(t *testing.T) {
    v := reflect.ValueOf(f)
    for i := 0; i < 10000; i++ {
        v.Call(nil)
    }
}

var x [][]byte

func f() {
    x = append(x, make([]byte, 10000))
}
$ go test -memprofile=x.prof x_test.go
ok      command-line-arguments  0.093s
$ go tool pprof -top x.test x.prof
100.50MB of 100.50MB total (  100%)
      flat  flat%   sum%        cum   cum%
  100.50MB   100%   100%   100.50MB   100%  reflect.Value.call
         0     0%   100%   100.50MB   100%  command-line-arguments.TestReflect
         0     0%   100%   100.50MB   100%  reflect.Value.Call
         0     0%   100%   100.50MB   100%  runtime.goexit
         0     0%   100%   100.50MB   100%  testing.tRunner
$ go tool pprof -top -runtime x.test x.prof
100.50MB of 100.50MB total (  100%)
Dropped 1 node (cum <= 0.50MB)
      flat  flat%   sum%        cum   cum%
  100.50MB   100%   100%   100.50MB   100%  runtime.makeslice
         0     0%   100%   100.50MB   100%  command-line-arguments.TestReflect
         0     0%   100%   100.50MB   100%  command-line-arguments.f
         0     0%   100%   100.50MB   100%  reflect.Value.Call
         0     0%   100%   100.50MB   100%  reflect.Value.call
         0     0%   100%   100.50MB   100%  runtime.call32
         0     0%   100%   100.50MB   100%  runtime.goexit
         0     0%   100%   100.50MB   100%  testing.tRunner
$

@rsc rsc changed the title runtime: make runtime.reflectcall followable by pprof cmd/pprof: make runtime.reflectcall followable by pprof Nov 5, 2015
@rsc
Copy link
Contributor

rsc commented Dec 5, 2015

We ran out of time for this in Go 1.6.

@rsc rsc modified the milestones: Unplanned, Go1.6 Dec 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants