Go pprof Concepts: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(8 intermediate revisions by the same user not shown)
Line 5: Line 5:
=Profile=
=Profile=


A '''profile''' is a collection of stack traces showing the call sequences that led to instances of a particular event, such as allocation. Packages can create and maintain their own profiles. The most common use is for tracking resources that must be explicitly closed, such as files or network connections.  
A '''profile''' is a collection of stack traces showing the call sequences that led to instances of a particular event, such as allocation, plus some additional metadata. Packages can create and maintain their own profiles. The most common use is for tracking resources that must be explicitly closed, such as files or network connections. Each profile has a unique name. There are a few predefined profiles: [[#goroutine|goroutine]], [[#heap|heap]], [[#threadcreate|threadcreate]], [[#block|block]], [[#mutex|mutex]] and [[#profile|profile]], which is the short for "CPU profile".


Each profile has a unique name.  
<code>[[Go_pprof_Operations#go_tool_pprof|go tool pprof]]</code> is the tool that can be used to analyze these profiles.
 
There are a few predefined profiles:


==<tt>goroutine</tt>==
==<tt>goroutine</tt>==
Line 17: Line 15:
The goroutines can be in one of the following states:
The goroutines can be in one of the following states:
* <code>running</code>
* <code>running</code>
* <code>chan receive, xxx minutes</code>
* <code>chan receive</code>[<code>, x minutes</code>]
* <code>syscall</code>[<code>, x minutes</code>]
* <code>select</code>[<code>, x minutes</code>]
* <code>IO wait</code>[<code>, x minutes</code>]
* <code>sync.Cond.Wait</code>[<code>, x minutes</code>]
* <code>semacquire</code>[<code>, x minutes</code>]
==<tt>heap</tt>==
The profile contains a sampling of all heap allocation. The stack traces in the heap profile are the stack trace at time of allocation. They might for code that is not running anymore.
 
==<tt>threadcreate</tt>==
The profile contains stack traces that led to the creation of new OS threads.
==<tt>block</tt>==
The profile contains stack traces that led to blocking on synchronization primitives.
==<tt>mutex</tt>==
The profile contains stack traces of holders of contended mutexes.
==<tt>profile</tt>==
This profile contains the CPU profile.
 
=<tt>trace</tt>=
<syntaxhighlight lang='bash'>
http://localhost:8080/debug/pprof/trace?seconds=5
</syntaxhighlight>
produces a trace, not a profile. The data collected as such can be viewed with <code>[[Go_pprof_Operations#go_tool_trace|go tool trace]]</code>.

Latest revision as of 04:14, 16 November 2024

External

Internal

Overview

Profile

A profile is a collection of stack traces showing the call sequences that led to instances of a particular event, such as allocation, plus some additional metadata. Packages can create and maintain their own profiles. The most common use is for tracking resources that must be explicitly closed, such as files or network connections. Each profile has a unique name. There are a few predefined profiles: goroutine, heap, threadcreate, block, mutex and profile, which is the short for "CPU profile".

go tool pprof is the tool that can be used to analyze these profiles.

goroutine

The profile contains the stack traces of all current goroutines. This is how you can pull it from the process with curl.

The goroutines can be in one of the following states:

  • running
  • chan receive[, x minutes]
  • syscall[, x minutes]
  • select[, x minutes]
  • IO wait[, x minutes]
  • sync.Cond.Wait[, x minutes]
  • semacquire[, x minutes]

heap

The profile contains a sampling of all heap allocation. The stack traces in the heap profile are the stack trace at time of allocation. They might for code that is not running anymore.

threadcreate

The profile contains stack traces that led to the creation of new OS threads.

block

The profile contains stack traces that led to blocking on synchronization primitives.

mutex

The profile contains stack traces of holders of contended mutexes.

profile

This profile contains the CPU profile.

trace

http://localhost:8080/debug/pprof/trace?seconds=5

produces a trace, not a profile. The data collected as such can be viewed with go tool trace.