mirror of
https://github.com/LBRYFoundation/lbry-sdk.git
synced 2025-09-02 18:25:14 +00:00
Add timing to hash announcements
This could potentially be a performance issue on reflector or any daemon with a large number of blobs.
This commit is contained in:
parent
3585d861ff
commit
56d394fb5f
1 changed files with 10 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
import binascii
|
import binascii
|
||||||
import collections
|
import collections
|
||||||
import logging
|
import logging
|
||||||
|
import time
|
||||||
|
|
||||||
from twisted.internet import defer, reactor
|
from twisted.internet import defer, reactor
|
||||||
|
|
||||||
|
@ -52,7 +53,11 @@ class DHTHashAnnouncer(object):
|
||||||
return dl
|
return dl
|
||||||
|
|
||||||
def _announce_hashes(self, hashes):
|
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 = []
|
ds = []
|
||||||
|
|
||||||
for h in hashes:
|
for h in hashes:
|
||||||
|
@ -74,7 +79,10 @@ class DHTHashAnnouncer(object):
|
||||||
# TODO: maybe make the 5 configurable
|
# TODO: maybe make the 5 configurable
|
||||||
self._concurrent_announcers += 1
|
self._concurrent_announcers += 1
|
||||||
announce()
|
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):
|
class DHTHashSupplier(object):
|
||||||
|
|
Loading…
Add table
Reference in a new issue