/debug/pprof
endpoint and metrics
over /debug/vars
endpoint. Each Dgraph data node has itβs own profiling and
metrics information. Below is a list of debugging information exposed by Dgraph
and the corresponding commands to retrieve them.
--expose_trace=true
flag, otherwise there metrics can be collected by
connecting to the instance over localhost.
/debug/prometheus_metrics
. See the Metrics section for the full
list of metrics.
go tool pprof
profiling tool built
into Go. The
βProfiling Go programsβ Go blog
post should help you get started with using pprof. Each Dgraph Zero and Dgraph
Alpha exposes a debug endpoint at /debug/pprof/<profile>
via the HTTP port.
top
to get a listing
of the top functions in the profile, web
to get a visual graph of the profile
opened in a web browser, or list
to display a code listing with profiling
information overlaid.
--profile_mode=block
and --block_rate=<N>
with N > 1.
/debug/pprof/
is available at the HTTP port of a Dgraph Zero or
Dgraph Alpha. From this page a link to the βfull goroutine stack dumpβ is
available (for example, on a Dgraph Alpha this page would be at
http://localhost:8080/debug/pprof/goroutine?debug=2
). Looking at the full
goroutine stack can be useful to understand goroutine usage at that moment.
debuginfo
goroutine
profile, you can use the debuginfo
command to collect all of these profiles,
along with several metrics.
You can run the command like this:
debuginfo
returns the tarballβs file name. If no
destination has been specified, the file is created in the same directory from
where you ran the debuginfo
command.
The following files contain the metrics collected by the debuginfo
command:
-m
)debuginfo
collects:
heap
cpu
state
health
jemalloc
trace
metrics
vars
trace
goroutine
block
mutex
threadcreate
jemalloc
and health
profiles:
cpu profile
: CPU profile determines where a program spends its time while
actively consuming CPU cycles (as opposed to while sleeping or waiting for
I/O).
heap
: Heap profile reports memory allocation samples; used to monitor
current and historical memory usage, and to check for memory leaks.
threadcreate
: Thread creation profile reports the sections of the program
that lead the creation of new OS threads.
goroutine
: Goroutine profile reports the stack traces of all current
goroutines.
block
: Block profile shows where goroutines block waiting on synchronization
primitives (including timer channels).
mutex
: Mutex profile reports the lock contentions. When you think your CPU
isnβt fully utilized due to a mutex contention, use this profile.
trace
: this capture a wide range of runtime events. Execution tracer is a
tool to detect latency and utilization problems. You can examine how well the
CPU is utilized, and when networking or syscalls are a cause of preemption for
the goroutines. Tracer is useful to identify poorly parallelized execution,
understand some of the core runtime events, and how your goroutines execute.
debug
tool--keyfile <path-to-keyfile>
option. This
file must contain the same key that was used to encrypt the βpβ directory.dgraph debug
tool can be used to inspect Dgraphβs posting list structure.
You can use the debug tool to inspect the data, schema, and indices of your
Dgraph cluster.
Some scenarios where the debug tool is useful:
0-name
. Note
that 0 is the namespace and name is the predicate.
chmod 600
{d}
: data key{i}
: index key{c}
: count key{r}
: reverse key{s}
: schema keyattr: name term: [1] [dgraph]
the [1]
shows that this is the term index
(0x1). In attr: description term: [8] [fast]
, the [8]
shows that
this is the full-text index (0x8). These IDs match the index IDs
in tok.go.
--lookup
flag for the specific
key.
attr: url uid: 1
is a string value.
fast
index for the <description>
predicate has UIDs 0x1 and
0x2.
--history
option.
{complete}
: Complete posting list{uid}
: UID posting list{delta}
: Delta posting list{empty}
: Empty posting list{item}
: Item posting list{deleted}
: Delete marker--parse_key
. This
doesnβt require a p directory.