1
0
mirror of https://github.com/golang/go synced 2024-09-23 21:20:13 -06:00
go/doc
Martin Möhrmann 7c58ef732e runtime: implement GODEBUG=inittrace=1 support
Setting inittrace=1 causes the runtime to emit a single line to standard error for
each package with init work, summarizing the execution time and memory allocation.

The emitted debug information for init functions can be used to find bottlenecks
or regressions in Go startup performance.

Packages with no init function work (user defined or compiler generated) are omitted.

Tracing plugin inits is not supported as they can execute concurrently. This would
make the implementation of tracing more complex while adding support for a very rare
use case. Plugin inits can be traced separately by testing a main package importing
the plugins package imports explicitly.

$ GODEBUG=inittrace=1 go test
init internal/bytealg @0.008 ms, 0 ms clock, 0 bytes, 0 allocs
init runtime @0.059 ms, 0.026 ms clock, 0 bytes, 0 allocs
init math @0.19 ms, 0.001 ms clock, 0 bytes, 0 allocs
init errors @0.22 ms, 0.004 ms clock, 0 bytes, 0 allocs
init strconv @0.24 ms, 0.002 ms clock, 32 bytes, 2 allocs
init sync @0.28 ms, 0.003 ms clock, 16 bytes, 1 allocs
init unicode @0.44 ms, 0.11 ms clock, 23328 bytes, 24 allocs
...

Inspired by stapelberg@google.com who instrumented doInit
in a prototype to measure init times with GDB.

Fixes #41378

Change-Id: Ic37c6a0cfc95488de9e737f5e346b8dbb39174e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/254659
Trust: Martin Möhrmann <moehrmann@google.com>
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-10-14 05:34:32 +00:00
..
articles doc/articles/wiki: add missing log import to net/http tutorial 2020-08-16 21:51:36 +00:00
codewalk doc: convert remaining bash tests to Go 2019-11-14 21:33:00 +00:00
gopher
play doc/play: match the hello world snippet in x/website 2019-10-23 22:43:37 +00:00
progs all: replace Replace(..., -1) with ReplaceAll(...) 2020-08-17 04:07:23 +00:00
asm.html doc/asm: add BP is callee-save paragraph 2020-09-01 14:54:08 +00:00
cmd.html doc: remove extra br tags 2020-02-23 01:23:41 +00:00
contribute.html doc: fix typo in contribute.html 2020-10-06 07:37:55 +00:00
debugging_with_gdb.html doc/debugging_with_gdb: fix the link of delve 2020-04-13 04:26:57 +00:00
diagnostics.html runtime: implement GODEBUG=inittrace=1 support 2020-10-14 05:34:32 +00:00
editors.html doc/editors.html: update VS Code Go extension url 2020-07-08 13:59:06 +00:00
effective_go.html doc: add note about missing lock in sample code 2020-06-30 13:02:41 +00:00
gccgo_contribute.html all: remove trailing whitespace from HTML files 2019-09-18 18:32:20 +00:00
gccgo_install.html doc/gccgo: change gold build instructions to use Git repository 2020-06-15 19:05:29 +00:00
go1.1.html
go1.2.html
go1.3.html doc: rewrite reference to plan9.bell-labs.com to 9p.io 2019-08-19 21:42:54 +00:00
go1.4.html
go1.5.html
go1.6.html doc: align documents link 2019-08-26 17:33:52 +00:00
go1.7.html doc: align documents link 2019-08-26 17:33:52 +00:00
go1.8.html doc: align documents link 2019-08-26 17:33:52 +00:00
go1.9.html doc: rename HTML element IDs to avoid duplicates 2020-02-05 14:32:50 +00:00
go1.10.html all: avoid awkward wording from CL 236857 2020-06-08 21:36:04 +00:00
go1.11.html doc: rename HTML element IDs to avoid duplicates 2020-02-05 14:32:50 +00:00
go1.12.html doc: align documents link 2019-08-26 17:33:52 +00:00
go1.13.html doc: rename HTML element IDs to avoid duplicates 2020-02-05 14:32:50 +00:00
go1.14.html doc/go1.14: document json.Umarshal map key support of TextUnmarshaler 2020-08-27 09:47:26 +00:00
go1.15.html doc/go1.15: include behavior updates to the context package 2020-08-12 23:25:46 +00:00
go1.16.html cmd/compile: split exported/non-exported methods for interface type 2020-10-09 02:14:32 +00:00
go1.html
go1compat.html
go_faq.html doc/faq: fix a grammar mistake 2020-06-25 02:59:06 +00:00
go_mem.html doc/mem: remove unnecessary pre tags within same snippet 2020-03-03 09:28:34 +00:00
go_spec.html spec: better variable name for operator example 2020-09-24 20:41:14 +00:00
go-logo-black.png
go-logo-blue.png
go-logo-white.png
help.html doc: add alt attribute to gopher image in help.html 2020-06-29 17:59:28 +00:00
ie.css
install-source.html doc: update install docs for 387->softfloat transition 2020-10-09 02:49:19 +00:00
install.html doc: update the minimum supported macOS version to 10.11 2020-04-01 18:26:02 +00:00
share.png
tos.html