summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/hashserv/server.py
diff options
context:
space:
mode:
authorAlexandre Marques <c137.marques@gmail.com>2025-03-12 11:22:04 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-03-13 16:52:44 +0000
commita4f833698289da86138fd4a401331baa563b5eed (patch)
tree3bcdd9688aaa9dbec6d2002a351196bbcb4d58b0 /bitbake/lib/hashserv/server.py
parentcb9bff9eac3670253076d5d09c6893e372be40a8 (diff)
downloadpoky-a4f833698289da86138fd4a401331baa563b5eed.tar.gz
bitbake: hashserv: Add `gc-mark-stream` command for batch hash marking
Implements the `gc-mark-stream` command to allow for marking equivalence entries in batch, by making use of stream mode communication to the server. The aim of this is to improve efficiency by reducing the impact of latency when marking a high volume of hash entries. Example usage of the new `gc-mark-stream` command: ``` $ cat << HASHES | \ ./bin/bitbake-hashclient --address "ws://localhost:8688/ws" gc-mark-stream "alive" unihash f37918cc02eb5a520b1aff86faacbc0a38124646 unihash af36b199320e611fbb16f1f277d3ee1d619ca58b taskhash a1117c1f5a7c9ab2f5a39cc6fe5e6152169d09c0 method oe.sstatesig.OEOuthashBasic HASHES ``` (Bitbake rev: c84715f28cd36666ea07a179d91b8c32ea0df8e7) Signed-off-by: Alexander Marques <c137.marques@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/hashserv/server.py')
-rw-r--r--bitbake/lib/hashserv/server.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/bitbake/lib/hashserv/server.py b/bitbake/lib/hashserv/server.py
index 68f64f983b..58f95c7bcd 100644
--- a/bitbake/lib/hashserv/server.py
+++ b/bitbake/lib/hashserv/server.py
@@ -10,6 +10,7 @@ import math
10import time 10import time
11import os 11import os
12import base64 12import base64
13import json
13import hashlib 14import hashlib
14from . import create_async_client 15from . import create_async_client
15import bb.asyncrpc 16import bb.asyncrpc
@@ -256,6 +257,7 @@ class ServerClient(bb.asyncrpc.AsyncServerConnection):
256 "backfill-wait": self.handle_backfill_wait, 257 "backfill-wait": self.handle_backfill_wait,
257 "remove": self.handle_remove, 258 "remove": self.handle_remove,
258 "gc-mark": self.handle_gc_mark, 259 "gc-mark": self.handle_gc_mark,
260 "gc-mark-stream": self.handle_gc_mark_stream,
259 "gc-sweep": self.handle_gc_sweep, 261 "gc-sweep": self.handle_gc_sweep,
260 "gc-status": self.handle_gc_status, 262 "gc-status": self.handle_gc_status,
261 "clean-unused": self.handle_clean_unused, 263 "clean-unused": self.handle_clean_unused,
@@ -584,6 +586,33 @@ class ServerClient(bb.asyncrpc.AsyncServerConnection):
584 return {"count": await self.db.gc_mark(mark, condition)} 586 return {"count": await self.db.gc_mark(mark, condition)}
585 587
586 @permissions(DB_ADMIN_PERM) 588 @permissions(DB_ADMIN_PERM)
589 async def handle_gc_mark_stream(self, request):
590 async def handler(line):
591 try:
592 decoded_line = json.loads(line)
593 except json.JSONDecodeError as exc:
594 raise bb.asyncrpc.InvokeError(
595 "Could not decode JSONL input '%s'" % line
596 ) from exc
597
598 try:
599 mark = decoded_line["mark"]
600 condition = decoded_line["where"]
601 if not isinstance(mark, str):
602 raise TypeError("Bad mark type %s" % type(mark))
603
604 if not isinstance(condition, dict):
605 raise TypeError("Bad condition type %s" % type(condition))
606 except KeyError as exc:
607 raise bb.asyncrpc.InvokeError(
608 "Input line is missing key '%s' " % exc
609 ) from exc
610
611 return json.dumps({"count": await self.db.gc_mark(mark, condition)})
612
613 return await self._stream_handler(handler)
614
615 @permissions(DB_ADMIN_PERM)
587 async def handle_gc_sweep(self, request): 616 async def handle_gc_sweep(self, request):
588 mark = request["mark"] 617 mark = request["mark"]
589 618