Change in vdsm[master]: WIP: add simple tracemalloc inspection tool
gerrit-hooks has posted comments on this change. Change subject: WIP: add simple tracemalloc inspection tool .. Patch Set 3: * Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0']) -- To view, visit https://gerrit.ovirt.org/48115 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ideb2652f345edb6f4a4d66c5299b601e53e85d33 Gerrit-PatchSet: 3 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Francesco Romani Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Jenkins CI RO Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[master]: WIP: add simple tracemalloc inspection tool
Francesco Romani has restored this change. Change subject: WIP: add simple tracemalloc inspection tool .. Restored -- To view, visit https://gerrit.ovirt.org/48115 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: restore Gerrit-Change-Id: Ideb2652f345edb6f4a4d66c5299b601e53e85d33 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Francesco Romani Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Jenkins CI RO Gerrit-Reviewer: gerrit-hooks ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org
Change in vdsm[master]: WIP: add simple tracemalloc inspection tool
gerrit-hooks has posted comments on this change. Change subject: WIP: add simple tracemalloc inspection tool .. Patch Set 2: * Update tracker: IGNORE, no Bug-Url found -- To view, visit https://gerrit.ovirt.org/48115 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ideb2652f345edb6f4a4d66c5299b601e53e85d33 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Francesco Romani Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Jenkins CI RO Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[master]: WIP: add simple tracemalloc inspection tool
Jenkins CI RO has abandoned this change. Change subject: WIP: add simple tracemalloc inspection tool .. Abandoned Abandoned due to no activity - please restore if still relevant -- To view, visit https://gerrit.ovirt.org/48115 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: Ideb2652f345edb6f4a4d66c5299b601e53e85d33 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Francesco Romani Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Jenkins CI RO Gerrit-Reviewer: gerrit-hooks ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[master]: WIP: add simple tracemalloc inspection tool
automat...@ovirt.org has posted comments on this change. Change subject: WIP: add simple tracemalloc inspection tool .. Patch Set 2: * Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3']) -- To view, visit https://gerrit.ovirt.org/48115 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ideb2652f345edb6f4a4d66c5299b601e53e85d33 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Francesco Romani Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: automat...@ovirt.org Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[master]: WIP: add simple tracemalloc inspection tool
automat...@ovirt.org has posted comments on this change. Change subject: WIP: add simple tracemalloc inspection tool .. Patch Set 1: * Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3']) -- To view, visit https://gerrit.ovirt.org/48115 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ideb2652f345edb6f4a4d66c5299b601e53e85d33 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Francesco Romani Gerrit-Reviewer: automat...@ovirt.org Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[master]: WIP: add simple tracemalloc inspection tool
Francesco Romani has uploaded a new change for review. Change subject: WIP: add simple tracemalloc inspection tool .. WIP: add simple tracemalloc inspection tool Change-Id: Ideb2652f345edb6f4a4d66c5299b601e53e85d33 Signed-off-by: Francesco Romani --- A contrib/memory-stats A contrib/tracemalloc.py 2 files changed, 592 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/15/48115/1 diff --git a/contrib/memory-stats b/contrib/memory-stats new file mode 100755 index 000..5625ad1 --- /dev/null +++ b/contrib/memory-stats @@ -0,0 +1,102 @@ +#!/usr/bin/env python +# +# Copyright 2015 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +# Refer to the README and COPYING files for full details of the license +# + +import argparse +import os +import sys +import time + +import tracemalloc + + +def eprint(s): +sys.stderr.write('%s\n' % s) + + +def _load(filename): +if filename: +eprint('Loading snapshot: "%s"' % filename) +before = time.time() +snap = tracemalloc.Snapshot.load(filename) +eprint('Loaded snapshot: "%s" in %.3f seconds' % ( +filename, time.time() - before)) +return snap +return None + + +def display_top(snapshot1, snapshot2=None, group_by='lineno', limit=10): +if snapshot2 is None: +top_stats = snapshot1.statistics(group_by) +else: +top_stats = snapshot2.compare_to(snapshot1, group_by) +print_stats(top_stats, limit) + + +def _print_sep(width=52): +print('-' * width) + + +def print_stats(top_stats, limit=10): +total = float(sum(stat.size for stat in top_stats)) +print("* Total allocated size: %.2f KiB" % (total / 1024.)) +print("* Top %s lines:" % limit) +_print_sep() +for index, stat in enumerate(top_stats[:limit], 1): +frame = stat.traceback[0] +# replace "/path/to/module/file.py" with "module/file.py" +filename = os.sep.join(frame.filename.split(os.sep)[-2:]) +where = "%s:%s" % (filename, frame.lineno) +print("#%3s: %-32s: %.2f KiB (%.2f%%)" + % (index, where, + stat.size / 1024., + (100. * stat.size) / total)) + +other = top_stats[limit:] +if other: +size = sum(stat.size for stat in other) +_print_sep() +where = "%i entries" % len(other) +print("rest: %-32s: %.2f KiB (%.2f%%)" + % (where, size / 1024., (100. * size) / total)) + + +ap = argparse.ArgumentParser(description='analyze tracemalloc snapshot') +ap.add_argument('snapshot', nargs='?', help='memory snapshot to analyze') +ap.add_argument('-c', '--compare-to', metavar='OS', dest='to_compare', +help='memory snapshot to compare') +ap.add_argument('-g', '--group-by', metavar='ATTR', dest='groupby', +default='lineno', +help='group samples by either: lineno, filename, traceback') +ap.add_argument('-l', '--limit', metavar='L', dest='limit', default=10, +type=int, +help='limit output to L top entries') + + +args = ap.parse_args() + +if not args.snapshot: +ap.print_help() +sys.exit(1) + +display_top(_load(args.snapshot), +_load(args.to_compare), +args.groupby, +args.limit) diff --git a/contrib/tracemalloc.py b/contrib/tracemalloc.py new file mode 100644 index 000..47b633e --- /dev/null +++ b/contrib/tracemalloc.py @@ -0,0 +1,490 @@ +# Copy of tracemalloc.py from pytracemalloc without _tracemalloc, +# to be able to read snapshot without having to install the _tracemaloc +# module. +from collections import Sequence, Iterable +import fnmatch +import linecache +import os.path +import pickle + + +try: +from functools import total_ordering +except ImportError: +# Python 2.6 +def total_ordering(cls): +# Function backported from Python 2.7 +convert = { +'__lt__': [('__gt__', lambda self, other: _not_op_and_not_eq(self.__lt__, self, other)), + ('__le__', lambda self, other: _op_or_eq(self.__lt__, self, other)), + ('__ge__', lambda self, other: _not_op(self.__lt__, other))], +'__le__': [('_