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

tools: add mutex profile to heapWatch #5638

Merged
merged 2 commits into from
Aug 7, 2023
Merged
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
20 changes: 20 additions & 0 deletions test/heapwatch/heapWatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ def get_heap_snapshot(self, snapshot_name=None, outdir=None):
def get_goroutine_snapshot(self, snapshot_name=None, outdir=None):
return self.get_pprof_snapshot('goroutine', snapshot_name, outdir)

def get_mutex_snapshot(self, snapshot_name=None, outdir=None):
return self.get_pprof_snapshot('mutex', snapshot_name, outdir)

def get_block_snapshot(self, snapshot_name=None, outdir=None):
return self.get_pprof_snapshot('block', snapshot_name, outdir)

def get_cpu_profile(self, snapshot_name=None, outdir=None, seconds=90):
seconds = int(seconds)
return self.get_pprof_snapshot('profile?seconds={}'.format(seconds), snapshot_name, outdir, timeout=seconds+20)
Expand Down Expand Up @@ -352,6 +358,12 @@ def do_snap(self, now, get_cpu=False, fraction=False):
if self.args.goroutine:
for ad in self.they:
ad.get_goroutine_snapshot(snapshot_name, outdir=self.args.out)
if self.args.mutex:
for ad in self.they:
ad.get_mutex_snapshot(snapshot_name, outdir=self.args.out)
if self.args.block:
for ad in self.they:
ad.get_block_snapshot(snapshot_name, outdir=self.args.out)
if self.args.metrics:
threads = []
for ad in self.they:
Expand Down Expand Up @@ -427,7 +439,9 @@ def main():
ap = argparse.ArgumentParser()
ap.add_argument('data_dirs', nargs='*', help='list paths to algorand datadirs to grab heap profile from')
ap.add_argument('--no-heap', dest='heaps', default=True, action='store_false', help='disable heap snapshot capture')
ap.add_argument('--block', default=False, action='store_true', help='also capture goroutines block profile')
ap.add_argument('--goroutine', default=False, action='store_true', help='also capture goroutine profile')
ap.add_argument('--mutex', default=False, action='store_true', help='also capture mutex profile')
ap.add_argument('--metrics', default=False, action='store_true', help='also capture /metrics counts')
ap.add_argument('--blockinfo', default=False, action='store_true', help='also capture block header info')
ap.add_argument('--period', default=None, help='seconds between automatically capturing')
Expand All @@ -452,6 +466,12 @@ def main():
else:
logging.basicConfig(level=logging.INFO)

if args.block:
print('Ensure algod is compiled with `runtime.SetBlockProfileRate()` set')

if args.mutex:
print('Ensure algod is compiled with `runtime.SetMutexProfileFraction()` set')

for nre in args.tf_name_re:
try:
# do re.compile just to check
Expand Down