From 0e46543c957fa3fc2341151b5ca632408a3c06b2 Mon Sep 17 00:00:00 2001 From: Lulu Zhang <lulu@buildbuddy.io> Date: Fri, 28 Jun 2024 16:51:21 -0700 Subject: [PATCH] add profile for open/close pebble iterator (#6964) --- enterprise/server/util/pebble/pebble.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/enterprise/server/util/pebble/pebble.go b/enterprise/server/util/pebble/pebble.go index 84d910449cb..1111f5b7d64 100644 --- a/enterprise/server/util/pebble/pebble.go +++ b/enterprise/server/util/pebble/pebble.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "runtime" + "runtime/pprof" "sync" "time" @@ -24,6 +25,8 @@ var ( warnAboutLeaks = flag.Bool("cache.pebble.warn_about_leaks", true, "If set, warn about leaked DB handles") ) +var pebbleIterProfile = pprof.NewProfile("pebble_open_iter") + var NoSync = pebble.NoSync var Sync = pebble.Sync var ErrNotFound = pebble.ErrNotFound @@ -187,6 +190,7 @@ type instrumentedIter struct { } func (i *instrumentedIter) Close() error { + pebbleIterProfile.Remove(i) return i.iter.Close() } @@ -393,7 +397,9 @@ func (idb *instrumentedDB) NewIter(o *pebble.IterOptions) (Iterator, error) { if err != nil { return nil, err } - return &instrumentedIter{idb, iter}, nil + res := &instrumentedIter{idb, iter} + pebbleIterProfile.Add(res, 1) + return res, nil } func (idb *instrumentedDB) NewBatch() Batch {