Skip to content

Commit

Permalink
internal/debug: use pprof goroutine writer for debug_stacks (ethereum…
Browse files Browse the repository at this point in the history
…#16892)

* debug: Use pprof goroutine writer in debug.Stacks() to ensure all goroutines are captured.

* Up to 64MB limit, previous code only captured first 1MB of goroutines.

* internal/debug: simplify stacks handler

* fix typo

* fix pointer receiver
  • Loading branch information
ryanschneider authored and firmianavan committed Aug 28, 2018
1 parent 7b0d58b commit e72764f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions internal/debug/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package debug

import (
"bytes"
"errors"
"io"
"os"
Expand Down Expand Up @@ -190,9 +191,9 @@ func (*HandlerT) WriteMemProfile(file string) error {

// Stacks returns a printed representation of the stacks of all goroutines.
func (*HandlerT) Stacks() string {
buf := make([]byte, 1024*1024)
buf = buf[:runtime.Stack(buf, true)]
return string(buf)
buf := new(bytes.Buffer)
pprof.Lookup("goroutine").WriteTo(buf, 2)
return buf.String()
}

// FreeOSMemory returns unused memory to the OS.
Expand Down

0 comments on commit e72764f

Please sign in to comment.