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: go1.3 profiles and tip profiles show different information #8942

Closed
rsc opened this issue Oct 16, 2014 · 7 comments
Closed

cmd/pprof: go1.3 profiles and tip profiles show different information #8942

rsc opened this issue Oct 16, 2014 · 7 comments
Milestone

Comments

@rsc
Copy link
Contributor

@rsc rsc commented Oct 16, 2014

pprof has a list of internal runtime functions to squelch.
that list needs to be updated for tip.
in particular, old profiles did not show malloc - instead a malloc is accounted to the
funtion in which it appears. but at tip profiles are showing malloc again.
@rsc
Copy link
Contributor Author

@rsc rsc commented Oct 16, 2014

Comment 1:

Related: the malloc that shows up is all stack-less because it is on the g0 stack.
Probably want to charge g0 ticks to the curg if there is one. Something like
diff -r 284a98e61e32 src/runtime/proc.c
--- a/src/runtime/proc.c    Wed Oct 15 19:33:15 2014 -0400
+++ b/src/runtime/proc.c    Wed Oct 15 23:13:50 2014 -0400
@@ -2436,7 +2436,7 @@
 void
 runtime·sigprof(uint8 *pc, uint8 *sp, uint8 *lr, G *gp, M *mp)
 {
-   int32 n;
+   int32 n, off;
    bool traceback;
    // Do not use global m in this function, use mp instead.
    // On windows one m is sending reports about all the g's, so m means a wrong thing.
@@ -2530,9 +2530,20 @@
       ((uint8*)runtime·gogo <= pc && pc < (uint8*)runtime·gogo + RuntimeGogoBytes))
        traceback = false;
 
+   off = 0;
+   if(gp == mp->g0 && mp->curg != nil) {
+       stk[0] = (uintptr)pc;
+       off = 1;
+       gp = mp->curg;
+       pc = (uint8*)gp->sched.pc;
+       sp = (uint8*)gp->sched.sp;
+       lr = 0;
+       traceback = true;
+   }
+
    n = 0;
    if(traceback)
-       n = runtime·gentraceback((uintptr)pc, (uintptr)sp, (uintptr)lr, gp, 0, stk,
nelem(stk), nil, nil, false);
+       n = runtime·gentraceback((uintptr)pc, (uintptr)sp, (uintptr)lr, gp, 0, stk+off,
nelem(stk)-off, nil, nil, false);
    if(!traceback || n <= 0) {
        // Normal traceback is impossible or has failed.
        // See if it falls into several common cases.
@dvyukov
Copy link
Member

@dvyukov dvyukov commented Oct 16, 2014

Comment 2:

There is also related issue
https://golang.org/issue/8867
@gopherbot
Copy link

@gopherbot gopherbot commented Oct 16, 2014

Comment 3:

CL https://golang.org/cl/159990043 mentions this issue.
@rsc
Copy link
Contributor Author

@rsc rsc commented Oct 16, 2014

Comment 4:

This issue was updated by revision 7ed8723.

This does not fully address issue #8942 but it does make
the profiles much more useful, until that issue can be
fixed completely.
LGTM=dvyukov
R=r, dvyukov
CC=golang-codereviews
https://golang.org/cl/159990043
@rsc
Copy link
Contributor Author

@rsc rsc commented Oct 17, 2014

Comment 5:

This issue was updated by revision 1ba977c.

This does not fully address issue #8942 but it does make
the profiles much more useful, until that issue can be
fixed completely.
LGTM=dvyukov
R=r, dvyukov
CC=golang-codereviews
https://golang.org/cl/159990043
»»»
TBR=dvyukov
CC=golang-codereviews
https://golang.org/cl/160030043
@rsc
Copy link
Contributor Author

@rsc rsc commented Nov 19, 2014

Comment 6:

Although it is still true that they show different information, they're still useful, so
they're good enough for now. Revisit for 1.5.

Labels changed: added release-go1.5, removed release-go1.4.

@rsc rsc added accepted labels Nov 19, 2014
@bradfitz bradfitz modified the milestone: Go1.5 Dec 16, 2014
@bradfitz bradfitz removed the release-go1.5 label Dec 16, 2014
@rsc rsc removed accepted labels Apr 14, 2015
@rsc
Copy link
Contributor Author

@rsc rsc commented Jul 14, 2015

I was just looking at pprof profiles and it seems okay now.
And the stack traces are useful on the system stack too.

@rsc rsc closed this Jul 14, 2015
@golang golang locked and limited conversation to collaborators Jul 13, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.