Fixed and cleaned up the server flush output a little. Also removed a check for pypy since getmemsize is no longer used.

This commit is contained in:
Griatch 2016-04-16 08:55:58 +02:00
parent 609c784b14
commit b0f51b02a6

View file

@ -662,10 +662,12 @@ class CmdServerLoad(MuxCommand):
if "flushmem" in self.switches: if "flushmem" in self.switches:
# flush the cache # flush the cache
prev, _ = _IDMAPPER.cache_size()
nflushed = _IDMAPPER.flush_cache() nflushed = _IDMAPPER.flush_cache()
string = "Flushed object idmapper cache. Python garbage " \ now, _ = _IDMAPPER.cache_size()
"collector recovered memory from %i objects." string = "The Idmapper cache freed |w{idmapper}|n database objects.\n" \
self.caller(string % nflushed) "The Python garbage collector freed |w{gc}|n Python instances total."
self.caller.msg(string.format(idmapper=(prev-now), gc=nflushed))
return return
# display active processes # display active processes
@ -739,19 +741,15 @@ class CmdServerLoad(MuxCommand):
string = "{wServer CPU and Memory load:{n\n%s" % loadtable string = "{wServer CPU and Memory load:{n\n%s" % loadtable
if not is_pypy: # object cache count (note that sys.getsiseof is not called so this works for pypy too.
# Cache size measurements are not available on PyPy total_num, cachedict = _IDMAPPER.cache_size()
# because it lacks sys.getsizeof sorted_cache = sorted([(key, num) for key, num in cachedict.items() if num > 0],
key=lambda tup: tup[1], reverse=True)
memtable = EvTable("entity name", "number", "idmapper %", align="l")
for tup in sorted_cache:
memtable.add_row(tup[0], "%i" % tup[1], "%.2f" % (float(tup[1]) / total_num * 100))
# object cache size string += "\n{w Entity idmapper cache:{n %i items\n%s" % (total_num, memtable)
total_num, cachedict = _IDMAPPER.cache_size()
sorted_cache = sorted([(key, num) for key, num in cachedict.items() if num > 0],
key=lambda tup: tup[1], reverse=True)
memtable = EvTable("entity name", "number", "idmapper %", align="l")
for tup in sorted_cache:
memtable.add_row(tup[0], "%i" % tup[1], "%.2f" % (float(tup[1]) / total_num * 100))
string += "\n{w Entity idmapper cache:{n %i items\n%s" % (total_num, memtable)
# return to caller # return to caller
self.caller.msg(string) self.caller.msg(string)