mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 13:09:50 +00:00
bitbake: hashserv: Add unihash-exists API
Adds API to check if the server is aware of the existence of a given unihash. This can be used as an optimization for sstate where a client can query the hash equivalence server to check if a unihash exists before querying the sstate cache. If the hash server isn't aware of the existence of a unihash, then there is very likely not a matching sstate object, so this should be able to significantly cut down on the number of negative hits on the sstate cache. (Bitbake rev: cfe0ac071cfb998e4a1dd263f8860b140843361a) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
be909636c6
commit
3bd2c69e70
@@ -234,6 +234,7 @@ class ServerClient(bb.asyncrpc.AsyncServerConnection):
|
||||
"get": self.handle_get,
|
||||
"get-outhash": self.handle_get_outhash,
|
||||
"get-stream": self.handle_get_stream,
|
||||
"exists-stream": self.handle_exists_stream,
|
||||
"get-stats": self.handle_get_stats,
|
||||
"get-db-usage": self.handle_get_db_usage,
|
||||
"get-db-query-columns": self.handle_get_db_query_columns,
|
||||
@@ -377,8 +378,7 @@ class ServerClient(bb.asyncrpc.AsyncServerConnection):
|
||||
await self.db.insert_unihash(data["method"], data["taskhash"], data["unihash"])
|
||||
await self.db.insert_outhash(data)
|
||||
|
||||
@permissions(READ_PERM)
|
||||
async def handle_get_stream(self, request):
|
||||
async def _stream_handler(self, handler):
|
||||
await self.socket.send_message("ok")
|
||||
|
||||
while True:
|
||||
@@ -400,35 +400,50 @@ class ServerClient(bb.asyncrpc.AsyncServerConnection):
|
||||
if l == "END":
|
||||
break
|
||||
|
||||
(method, taskhash) = l.split()
|
||||
# self.logger.debug('Looking up %s %s' % (method, taskhash))
|
||||
row = await self.db.get_equivalent(method, taskhash)
|
||||
|
||||
if row is not None:
|
||||
msg = row["unihash"]
|
||||
# self.logger.debug('Found equivalent task %s -> %s', (row['taskhash'], row['unihash']))
|
||||
elif self.upstream_client is not None:
|
||||
upstream = await self.upstream_client.get_unihash(method, taskhash)
|
||||
if upstream:
|
||||
msg = upstream
|
||||
else:
|
||||
msg = ""
|
||||
else:
|
||||
msg = ""
|
||||
|
||||
msg = await handler(l)
|
||||
await self.socket.send(msg)
|
||||
finally:
|
||||
request_measure.end()
|
||||
self.request_sample.end()
|
||||
|
||||
# Post to the backfill queue after writing the result to minimize
|
||||
# the turn around time on a request
|
||||
if upstream is not None:
|
||||
await self.server.backfill_queue.put((method, taskhash))
|
||||
|
||||
await self.socket.send("ok")
|
||||
return self.NO_RESPONSE
|
||||
|
||||
@permissions(READ_PERM)
|
||||
async def handle_get_stream(self, request):
|
||||
async def handler(l):
|
||||
(method, taskhash) = l.split()
|
||||
# self.logger.debug('Looking up %s %s' % (method, taskhash))
|
||||
row = await self.db.get_equivalent(method, taskhash)
|
||||
|
||||
if row is not None:
|
||||
# self.logger.debug('Found equivalent task %s -> %s', (row['taskhash'], row['unihash']))
|
||||
return row["unihash"]
|
||||
|
||||
if self.upstream_client is not None:
|
||||
upstream = await self.upstream_client.get_unihash(method, taskhash)
|
||||
if upstream:
|
||||
await self.server.backfill_queue.put((method, taskhash))
|
||||
return upstream
|
||||
|
||||
return ""
|
||||
|
||||
return await self._stream_handler(handler)
|
||||
|
||||
@permissions(READ_PERM)
|
||||
async def handle_exists_stream(self, request):
|
||||
async def handler(l):
|
||||
if await self.db.unihash_exists(l):
|
||||
return "true"
|
||||
|
||||
if self.upstream_client is not None:
|
||||
if await self.upstream_client.unihash_exists(l):
|
||||
return "true"
|
||||
|
||||
return "false"
|
||||
|
||||
return await self._stream_handler(handler)
|
||||
|
||||
async def report_readonly(self, data):
|
||||
method = data["method"]
|
||||
outhash = data["outhash"]
|
||||
|
||||
Reference in New Issue
Block a user