Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
feat: also include pypyjit's get_stats_asmmemmgr
Browse files Browse the repository at this point in the history
issue #802
  • Loading branch information
pjenvey committed Mar 3, 2017
1 parent b1cdf4e commit fcf5b8b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
25 changes: 24 additions & 1 deletion autopush/memusage.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def trap_err(func, *args, **kwargs):
stderr=subprocess.STDOUT)
buf.writelines([pmap, '\n\n'])
trap_err(dump_rpy_heap, buf)
trap_err(get_stats_asmmemmgr, buf)
return buf.getvalue()


Expand All @@ -41,9 +42,31 @@ def dump_rpy_heap(stream): # pragma: nocover

with tempfile.NamedTemporaryFile('wb') as fp:
gc._dump_rpy_heap(fp.fileno())
stream.write("{} size: {}\n".format(fp.name, os.stat(fp.name).st_size))
try:
fpsize = os.stat(fp.name).st_size
except OSError:
pass
else:
stream.write("{} size: {}\n".format(fp.name, fpsize))
stat = Stat()
stat.summarize(fp.name, stream=None)
stat.load_typeids(zlib.decompress(gc.get_typeids_z()).split("\n"))
stream.write('\n\n')
stat.print_summary(stream)


def get_stats_asmmemmgr(stream): # pragma: nocover
"""Write PyPy's get_stats_asmmemmgr to the specified stream
(The raw memory currently used by the JIT backend)
"""
try:
import pypyjit
except ImportError:
# not PyPy or no jit?
return

stream.write('\n\nget_stats_asmmemmgr: ')
stream.write(repr(pypyjit.get_stats_asmmemmgr()))
stream.write('\n')
1 change: 1 addition & 0 deletions autopush/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2125,6 +2125,7 @@ def test_memusage(self):
if hasattr(sys, 'pypy_version_info'): # pragma: nocover
ok_('size: ' in body)
ok_('rpy_unicode' in body)
ok_('get_stats_asmmemmgr: (' in body)


@inlineCallbacks
Expand Down

0 comments on commit fcf5b8b

Please sign in to comment.