From fa792a6a9536263bcbac8aa29da147a987ffe854 Mon Sep 17 00:00:00 2001 From: Philip Jenvey Date: Mon, 19 Jun 2017 08:16:10 -0700 Subject: [PATCH 1/2] feat: dump pmap -XX/X if available issue #802 --- autopush/memusage.py | 21 ++++++++++++++++++--- autopush/tests/test_integration.py | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/autopush/memusage.py b/autopush/memusage.py index 9a187ef4..0c5dd60c 100644 --- a/autopush/memusage.py +++ b/autopush/memusage.py @@ -26,14 +26,29 @@ def trap_err(func, *args, **kwargs): buf.writelines([repr(rusage), '\n\n']) trap_err(objgraph.show_most_common_types, limit=0, file=buf) buf.write('\n\n') - pmap = trap_err(subprocess.check_output, ['pmap', '-x', str(os.getpid())], - stderr=subprocess.STDOUT) - buf.writelines([pmap, '\n\n']) + trap_err(pmap_extended, buf) trap_err(dump_rpy_heap, buf) trap_err(get_stats_asmmemmgr, buf) return buf.getvalue() +def pmap_extended(stream): + """Write pmap (w/ the most extended stats supported) to stream""" + pid = str(os.getpid()) + # -XX/-X are recent linux only + ex_args = ['XX', 'X', 'x'] + while True: + cmd = ['pmap', '-' + ex_args.pop(0), pid] + try: + pmap = subprocess.check_output(cmd, stderr=subprocess.STDOUT) + except subprocess.CalledProcessError: # pragma: nocover + if not ex_args: + raise + else: + stream.writelines([' '.join(cmd[:2]), '\n', pmap, '\n\n']) + break + + def dump_rpy_heap(stream): # pragma: nocover """Write PyPy's gcdump to the specified stream""" if not hasattr(gc, '_dump_rpy_heap'): diff --git a/autopush/tests/test_integration.py b/autopush/tests/test_integration.py index 225577d5..b4007743 100644 --- a/autopush/tests/test_integration.py +++ b/autopush/tests/test_integration.py @@ -2179,7 +2179,7 @@ def test_memusage(self): ok_('rusage' in body) ok_('Logger' in body) if find_executable('pmap'): - ok_('RSS' in body) # pmap -x output + ok_('RSS' in body or 'Rss' in body) # pmap -x or -XX/X output if hasattr(sys, 'pypy_version_info'): # pragma: nocover ok_('size: ' in body) ok_('rpy_unicode' in body) From 474c84d6064d8a12b5d3a55ff818c12d4480492a Mon Sep 17 00:00:00 2001 From: Philip Jenvey Date: Mon, 19 Jun 2017 09:33:04 -0700 Subject: [PATCH 2/2] chore: tag 1.32.1 --- CHANGELOG.md | 10 ++++++++++ autopush/__init__.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index def76a24..9bcf1db9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ + +## 1.32.1 (2017-06-19) + + +#### Features + +* dump pmap -XX/X if available ([fa792a6a](https://github.com/mozilla-services/autopush/commit/fa792a6a9536263bcbac8aa29da147a987ffe854)) + + + ## 1.32.0 (2017-06-15) diff --git a/autopush/__init__.py b/autopush/__init__.py index 024294e2..4ee524b7 100644 --- a/autopush/__init__.py +++ b/autopush/__init__.py @@ -1 +1 @@ -__version__ = '1.32.0' # pragma: nocover +__version__ = '1.32.1' # pragma: nocover