Author: fijal Branch: Changeset: r93771:f59f5814a43c Date: 2018-02-06 14:39 +0100 http://bitbucket.org/pypy/pypy/changeset/f59f5814a43c/
Log: add optionality about memory pressure, defaulting to False diff --git a/pypy/module/gc/app_referents.py b/pypy/module/gc/app_referents.py --- a/pypy/module/gc/app_referents.py +++ b/pypy/module/gc/app_referents.py @@ -69,28 +69,51 @@ return "%.1fMB" % (v / 1024. / 1024.) def repr(self): - return """Total memory consumed: -GC used: %s (peak: %s) -raw assembler used: %s -memory pressure: %s ------------------------------ -Total: %s + if self._s.total_memory_pressure != -1: + return """Total memory consumed: + GC used: %s (peak: %s) + raw assembler used: %s + memory pressure: %s + ----------------------------- + Total: %s -Total memory allocated: -GC allocated: %s (peak: %s) -raw assembler allocated: %s -memory pressure: %s ------------------------------ -Total: %s -""" % (self.total_gc_memory, self.peak_memory, - self.jit_backend_used, - self.total_memory_pressure, - self.memory_used_sum, + Total memory allocated: + GC allocated: %s (peak: %s) + raw assembler allocated: %s + memory pressure: %s + ----------------------------- + Total: %s + """ % (self.total_gc_memory, self.peak_memory, + self.jit_backend_used, + self.total_memory_pressure, + self.memory_used_sum, - self.total_allocated_memory, self.peak_allocated_memory, - self.jit_backend_allocated, - self.total_memory_pressure, - self.memory_allocated_sum) + self.total_allocated_memory, self.peak_allocated_memory, + self.jit_backend_allocated, + self.total_memory_pressure, + self.memory_allocated_sum) + else: + return """Total memory consumed: + GC used: %s (peak: %s) + raw assembler used: %s + ----------------------------- + Total: %s + + Total memory allocated: + GC allocated: %s (peak: %s) + raw assembler allocated: %s + memory pressure: %s + ----------------------------- + Total: %s + """ % (self.total_gc_memory, self.peak_memory, + self.jit_backend_used, + self.memory_used_sum, + + self.total_allocated_memory, self.peak_allocated_memory, + self.jit_backend_allocated, + self.total_memory_pressure, + self.memory_allocated_sum) + def get_stats(): return GcStats(gc._get_stats()) diff --git a/pypy/module/gc/referents.py b/pypy/module/gc/referents.py --- a/pypy/module/gc/referents.py +++ b/pypy/module/gc/referents.py @@ -172,8 +172,11 @@ return space.newlist(list_w) class W_GcStats(W_Root): - def __init__(self): - self.total_memory_pressure = rgc.get_stats(rgc.TOTAL_MEMORY_PRESSURE) + def __init__(self, memory_pressure): + if memory_pressure: + self.total_memory_pressure = rgc.get_stats(rgc.TOTAL_MEMORY_PRESSURE) + else: + self.total_memory_pressure = -1 self.total_gc_memory = rgc.get_stats(rgc.TOTAL_MEMORY) self.total_allocated_memory = rgc.get_stats(rgc.TOTAL_ALLOCATED_MEMORY) self.peak_memory = rgc.get_stats(rgc.PEAK_MEMORY) @@ -198,5 +201,6 @@ cls=W_GcStats, wrapfn="newint"), ) -def get_stats(space): - return W_GcStats() +@unwrap_spec(memory_pressure=bool) +def get_stats(space, memory_pressure=False): + return W_GcStats(memory_pressure) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit