From 51f207f89f2db47e710891ea4c2819782b011c5f Mon Sep 17 00:00:00 2001 From: rob-deutsch Date: Sat, 29 Sep 2018 16:45:12 +1000 Subject: [PATCH] debug-guide.md added memory statistics command License: MIT Signed-off-by: Rob Deutsch --- docs/debug-guide.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/debug-guide.md b/docs/debug-guide.md index b7f5e0b42d38..267d5c1e0927 100644 --- a/docs/debug-guide.md +++ b/docs/debug-guide.md @@ -5,7 +5,8 @@ This is a document for helping debug go-ipfs. Please add to it if you can! ### Table of Contents - [Beginning](#beginning) - [Analysing the stack dump](#analysing-the-stack-dump) -- [Analyzing the CPU Profile](#analyzing-the-cpu-profile) +- [Analysing the CPU Profile](#analysing-the-cpu-profile) +- [Analysing vars and memory statistics](#analysing-vars-and-memory-statistics) - [Other](#other) ### Beginning @@ -20,6 +21,8 @@ profiling information. - `curl localhost:5001/debug/pprof/profile > ipfs.cpuprof` - heap trace dump - `curl localhost:5001/debug/pprof/heap > ipfs.heap` +- memory statistics (in json, see "memstats" object) + - `curl localhost:5001/debug/vars > ipfs.vars` - system information - `ipfs diag sys > ipfs.sysinfo` @@ -75,18 +78,22 @@ that goroutine in the middle of a short wait for something. If the wait time is over a few minutes, that either means that goroutine doesn't do much, or something is pretty wrong. -### Analyzing the CPU Profile +### Analysing the CPU Profile The go team wrote an [excellent article on profiling go programs](http://blog.golang.org/profiling-go-programs). If you've already gathered the above information, you can skip down to where they start talking -about `go tool pprof`. My go-to method of analyzing these is to run the `web` +about `go tool pprof`. My go-to method of analysing these is to run the `web` command, which generates an SVG dotgraph and opens it in your browser. This is the quickest way to easily point out where the hot spots in the code are. +### Analysing vars and memory statistics + +The output is JSON formatted and includes badger store statistics, the command line run, and the output from Go's [runtime.ReadMemStats](https://golang.org/pkg/runtime/#ReadMemStats). The [MemStats](https://golang.org/pkg/runtime/#MemStats) has useful information about memory allocation and garbage collection. + ### Other -If you have any questions, or want us to analyze some weird go-ipfs behaviour, +If you have any questions, or want us to analyse some weird go-ipfs behaviour, just let us know, and be sure to include all the profiling information mentioned at the top.