Skip to content

Commit

Permalink
debug-guide.md added memory statistics command
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Rob Deutsch <rdeutschob@gmail.com>
  • Loading branch information
rob-deutsch committed Oct 1, 2018
1 parent c4398fe commit 51f207f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions docs/debug-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`

Expand Down Expand Up @@ -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.

0 comments on commit 51f207f

Please sign in to comment.