From ab3d9bd0808196e66eecb43ad0728abec1aab9df Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Tue, 29 Dec 2020 21:40:39 -0500 Subject: [PATCH 1/2] block cache metrics --- lbry/wallet/server/daemon.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lbry/wallet/server/daemon.py b/lbry/wallet/server/daemon.py index 654b4337e..c6f4db3d2 100644 --- a/lbry/wallet/server/daemon.py +++ b/lbry/wallet/server/daemon.py @@ -55,7 +55,7 @@ class Daemon: self.available_rpcs = {} self.connector = aiohttp.TCPConnector() self._block_hash_cache = LRUCache(100000) - self._block_cache = LRUCache(10000) + self._block_cache = LRUCache(2**16, metric_name='block', namespace=NAMESPACE) async def close(self): if self.connector: @@ -249,8 +249,10 @@ class Daemon: async def deserialised_block(self, hex_hash): """Return the deserialised block with the given hex hash.""" - if not self._block_cache.get(hex_hash): - self._block_cache[hex_hash] = await self._send_single('getblock', (hex_hash, True)) + if hex_hash not in self._block_cache: + block = await self._send_single('getblock', (hex_hash, True)) + self._block_cache[hex_hash] = block + return block return self._block_cache[hex_hash] async def raw_blocks(self, hex_hashes): From 0758b85179b3558338a905399bb7ebbb43c2be9e Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Tue, 29 Dec 2020 21:41:07 -0500 Subject: [PATCH 2/2] skip null args given to channel_ids in claim search --- lbry/wallet/server/db/reader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lbry/wallet/server/db/reader.py b/lbry/wallet/server/db/reader.py index a3736750c..dc61dafe0 100644 --- a/lbry/wallet/server/db/reader.py +++ b/lbry/wallet/server/db/reader.py @@ -283,7 +283,7 @@ def claims_query(cols, for_count=False, **constraints) -> Tuple[str, Dict]: channel_ids = constraints.pop('channel_ids') if channel_ids: constraints['claim.channel_hash__in'] = { - unhexlify(cid)[::-1] for cid in channel_ids + unhexlify(cid)[::-1] for cid in channel_ids if cid } if 'not_channel_ids' in constraints: not_channel_ids = constraints.pop('not_channel_ids')