aboutsummaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
authorRyan Schneider <ryanleeschneider@gmail.com>2018-06-14 21:58:44 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-06-14 21:58:44 +0800
commit897ea01d5ffa4204f1a58353e7cb6e1bbdf096aa (patch)
tree53eeaecd9e22eef4bed7dc08a140920567a46ad1 /internal
parentec192f18b49907ba8a6eeb5ee33119bab962a274 (diff)
downloaddexon-897ea01d5ffa4204f1a58353e7cb6e1bbdf096aa.tar
dexon-897ea01d5ffa4204f1a58353e7cb6e1bbdf096aa.tar.gz
dexon-897ea01d5ffa4204f1a58353e7cb6e1bbdf096aa.tar.bz2
dexon-897ea01d5ffa4204f1a58353e7cb6e1bbdf096aa.tar.lz
dexon-897ea01d5ffa4204f1a58353e7cb6e1bbdf096aa.tar.xz
dexon-897ea01d5ffa4204f1a58353e7cb6e1bbdf096aa.tar.zst
dexon-897ea01d5ffa4204f1a58353e7cb6e1bbdf096aa.zip
internal/debug: use pprof goroutine writer for debug_stacks (#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
Diffstat (limited to 'internal')
-rw-r--r--internal/debug/api.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/internal/debug/api.go b/internal/debug/api.go
index 048b7d763..86a4218f6 100644
--- a/internal/debug/api.go
+++ b/internal/debug/api.go
@@ -21,6 +21,7 @@
package debug
import (
+ "bytes"
"errors"
"io"
"os"
@@ -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.