You've already forked go-profiler-notes
mirror of
https://github.com/DataDog/go-profiler-notes.git
synced 2025-07-15 23:54:16 +02:00
toc
This commit is contained in:
15
goroutine.md
15
goroutine.md
@ -2,6 +2,21 @@ This document was last updated for `go1.15.6` but probably still applies to olde
|
||||
|
||||
# Goroutine Profiling in Go
|
||||
|
||||
- [Goroutine Profiling in Go](#goroutine-profiling-in-go)
|
||||
* [Description](#description)
|
||||
* [Overhead](#overhead)
|
||||
* [Goroutine Properties](#goroutine-properties)
|
||||
* [APIs](#apis)
|
||||
+ [[`runtime.Stack()`](https://golang.org/pkg/runtime/#Stack) / [`pprof.Lookup(debug=2)`](https://golang.org/pkg/runtime/pprof/#Lookup)](#--runtimestack-----https---golangorg-pkg-runtime--stack-------pproflookup-debug-2----https---golangorg-pkg-runtime-pprof--lookup-)
|
||||
+ [[`pprof.Lookup(debug=1)`](https://golang.org/pkg/runtime/pprof/#Lookup)](#--pproflookup-debug-1----https---golangorg-pkg-runtime-pprof--lookup-)
|
||||
+ [[`pprof.Lookup(debug=0)`](https://golang.org/pkg/runtime/pprof/#Lookup)](#--pproflookup-debug-0----https---golangorg-pkg-runtime-pprof--lookup-)
|
||||
+ [[`runtime.GoroutineProfile()`](https://golang.org/pkg/runtime/#GoroutineProfile)](#--runtimegoroutineprofile-----https---golangorg-pkg-runtime--goroutineprofile-)
|
||||
+ [[`net/http/pprof`](https://golang.org/pkg/net/http/pprof/)](#--net-http-pprof---https---golangorg-pkg-net-http-pprof--)
|
||||
* [History](#history)
|
||||
* [Disclaimers](#disclaimers)
|
||||
|
||||
## Description
|
||||
|
||||
The Go runtime keeps track of all goroutines in a simple slice called [allgs](https://github.com/golang/go/blob/3a778ff50f7091b8a64875c8ed95bfaacf3d334c/src/runtime/proc.go#L500). It contains both active and dead goroutines. The latter are kept around for reuse when new goroutines are spawned.
|
||||
|
||||
Go has various APIs to inspect the active goroutines in `allgs` along with their current stack trace, as well as various other properties. Some APIs expose this information as statistical summaries, while other APIs provide information for each individual goroutine.
|
||||
|
Reference in New Issue
Block a user