Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(zero): Bring in jemalloc debugging to Zero. #7070

Merged
merged 3 commits into from
Dec 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions dgraph/cmd/alpha/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import (
"github.com/dgraph-io/dgraph/worker"
"github.com/dgraph-io/dgraph/x"
"github.com/dgraph-io/ristretto/z"
"github.com/dustin/go-humanize"
"github.com/golang/glog"
"github.com/pkg/errors"
"github.com/spf13/cast"
Expand Down Expand Up @@ -333,16 +332,6 @@ func healthCheck(w http.ResponseWriter, r *http.Request) {
_, _ = w.Write(resp.Json)
}

func jemallocHandler(w http.ResponseWriter, r *http.Request) {
x.AddCorsHeaders(w)

na := z.NumAllocBytes()
fmt.Fprintf(w, "Num Allocated Bytes: %s [%d]\n",
humanize.IBytes(uint64(na)), na)
fmt.Fprintf(w, "Allocators:\n%s\n", z.Allocators())
fmt.Fprintf(w, "%s\n", z.Leaks())
}

func stateHandler(w http.ResponseWriter, r *http.Request) {
var err error
x.AddCorsHeaders(w)
Expand Down Expand Up @@ -436,7 +425,7 @@ func setupServer(closer *z.Closer) {
http.HandleFunc("/alter", alterHandler)
http.HandleFunc("/health", healthCheck)
http.HandleFunc("/state", stateHandler)
http.HandleFunc("/jemalloc", jemallocHandler)
http.HandleFunc("/jemalloc", x.JemallocHandler)

// TODO: Figure out what this is for?
http.HandleFunc("/debug/store", storeStatsHandler)
Expand Down
1 change: 1 addition & 0 deletions dgraph/cmd/zero/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ func run() {
http.HandleFunc("/moveTablet", st.moveTablet)
http.HandleFunc("/assign", st.assign)
http.HandleFunc("/enterpriseLicense", st.applyEnterpriseLicense)
http.HandleFunc("/jemalloc", x.JemallocHandler)
zpages.Handle(http.DefaultServeMux, "/z")

// This must be here. It does not work if placed before Grpc init.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/OneOfOne/xxhash v1.2.5 // indirect
github.com/blevesearch/bleve v1.0.13
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd
github.com/dgraph-io/badger/v2 v2.0.1-rc1.0.20201205014101-3a4d8e7399b7
github.com/dgraph-io/badger/v2 v2.0.1-rc1.0.20201205055457-63726a849024
github.com/dgraph-io/dgo/v200 v200.0.0-20200805103119-a3544c464dd6
github.com/dgraph-io/gqlgen v0.13.2
github.com/dgraph-io/gqlparser/v2 v2.1.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgraph-io/badger v1.6.0 h1:DshxFxZWXUcO0xX476VJC07Xsr6ZCBVRHKZ93Oh7Evo=
github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4=
github.com/dgraph-io/badger/v2 v2.0.1-rc1.0.20201205014101-3a4d8e7399b7 h1:vqS1c9IRwTMS0Kb/OaLziwkQvk4h63j7mLVsku27fnk=
github.com/dgraph-io/badger/v2 v2.0.1-rc1.0.20201205014101-3a4d8e7399b7/go.mod h1:5RUGROQEPbBw8Ba5Q4Tff8/dgwoJM6EeJCsCOLgSeek=
github.com/dgraph-io/badger/v2 v2.0.1-rc1.0.20201205055457-63726a849024 h1:hj/5tQ6gD8ucfbobNcBrv8v5XmpIGGQy3ZQSloh2rfA=
github.com/dgraph-io/badger/v2 v2.0.1-rc1.0.20201205055457-63726a849024/go.mod h1:5RUGROQEPbBw8Ba5Q4Tff8/dgwoJM6EeJCsCOLgSeek=
github.com/dgraph-io/dgo/v200 v200.0.0-20200805103119-a3544c464dd6 h1:toHzMCdCUgYsjM0cW9+wafnKFXfp1HizIJUyzihN+vk=
github.com/dgraph-io/dgo/v200 v200.0.0-20200805103119-a3544c464dd6/go.mod h1:rHa+h3kI4M8ASOirxyIyNeXBfHFgeskVUum2OrDMN3U=
github.com/dgraph-io/gqlgen v0.13.2 h1:TNhndk+eHKj5qE7BenKKSYdSIdOGhLqxR1rCiMso9KM=
Expand Down
11 changes: 11 additions & 0 deletions x/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
datadog "github.com/DataDog/opencensus-go-exporter-datadog"
"github.com/dgraph-io/badger/v2"
"github.com/dgraph-io/ristretto/z"
"github.com/dustin/go-humanize"
"github.com/golang/glog"
"github.com/prometheus/client_golang/prometheus"
"github.com/spf13/viper"
Expand Down Expand Up @@ -565,3 +566,13 @@ func getMemUsage() int {

return rss * os.Getpagesize()
}

func JemallocHandler(w http.ResponseWriter, r *http.Request) {
AddCorsHeaders(w)

na := z.NumAllocBytes()
fmt.Fprintf(w, "Num Allocated Bytes: %s [%d]\n",
humanize.IBytes(uint64(na)), na)
fmt.Fprintf(w, "Allocators:\n%s\n", z.Allocators())
fmt.Fprintf(w, "%s\n", z.Leaks())
}