From 56d394fb5f64f1bfdea3e61713ecbf73580d808c Mon Sep 17 00:00:00 2001 From: Job Evers-Meltzer Date: Wed, 14 Dec 2016 16:52:26 -0600 Subject: [PATCH] Add timing to hash announcements This could potentially be a performance issue on reflector or any daemon with a large number of blobs. --- lbrynet/core/server/DHTHashAnnouncer.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lbrynet/core/server/DHTHashAnnouncer.py b/lbrynet/core/server/DHTHashAnnouncer.py index 8ce55ffd9..d41a19e74 100644 --- a/lbrynet/core/server/DHTHashAnnouncer.py +++ b/lbrynet/core/server/DHTHashAnnouncer.py @@ -1,6 +1,7 @@ import binascii import collections import logging +import time from twisted.internet import defer, reactor @@ -52,7 +53,11 @@ class DHTHashAnnouncer(object): return dl def _announce_hashes(self, hashes): - + if not hashes: + return + log.debug('Announcing %s hashes', len(hashes)) + # TODO: add a timeit decorator + start = time.time() ds = [] for h in hashes: @@ -74,7 +79,10 @@ class DHTHashAnnouncer(object): # TODO: maybe make the 5 configurable self._concurrent_announcers += 1 announce() - return defer.DeferredList(ds) + d = defer.DeferredList(ds) + d.addCallback(lambda _: log.debug('Took %s seconds to announce %s hashes', + time.time() - start, len(hashes))) + return d class DHTHashSupplier(object):