Compare commits

...

11 commits

Author SHA1 Message Date
Amber Brown e5f2f40256 make this a bit better 2018-11-07 07:05:50 +11:00
Amber Brown c2fab95215 make it gc as well 2018-11-07 06:56:01 +11:00
Amber Brown 649a7fbf88 make it less often 2018-11-07 06:53:29 +11:00
Amber Brown 090c99c5a1 make it less often 2018-11-07 06:51:15 +11:00
Amber Brown 44047bd2cf make it less often 2018-11-07 06:48:29 +11:00
Amber Brown 59ab507bc5 fix 2018-11-07 06:45:25 +11:00
Amber Brown e6e7bb0957 fix 2018-11-07 06:44:40 +11:00
Amber Brown 059c32f6b0 fix 2018-11-07 06:43:36 +11:00
Amber Brown 70738a2749 fix 2018-11-07 06:43:18 +11:00
Amber Brown 58efa093f4 try a thing 2018-11-07 06:42:19 +11:00
Amber Brown 4d6857a3fa tracemalloc 2018-11-07 06:08:35 +11:00

View file

@ -406,6 +406,13 @@ class SynapseService(service.Service):
def run(hs):
import tracemalloc
import gc
snapshots = []
snapshots.append(tracemalloc.take_snapshot())
PROFILE_SYNAPSE = False
if PROFILE_SYNAPSE:
def profile(func):
@ -568,6 +575,19 @@ def run(hs):
if hs.config.daemonize and hs.config.print_pidfile:
print(hs.config.pid_file)
def collect_stats():
gc.collect()
new = tracemalloc.take_snapshot()
stats = new.compare_to(snapshots[0], 'lineno')
for stat in stats[:10]:
print("{} new KiB {} total KiB {} new {} total memory blocks: ".format(stat.size_diff/1024, stat.size / 1024, stat.count_diff ,stat.count))
for line in stat.traceback.format():
print(line)
clock.looping_call(collect_stats, 60*1000)
_base.start_reactor(
"synapse-homeserver",
hs.config.soft_file_limit,
@ -586,6 +606,5 @@ def main():
hs = setup(sys.argv[1:])
run(hs)
if __name__ == '__main__':
main()