diff options
author | Joshua Watt <JPEWhacker@gmail.com> | 2024-02-18 15:59:46 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-02-19 11:58:12 +0000 |
commit | 1effd1014d9140905093efe25eeefedb28a10875 (patch) | |
tree | b34fb1d26f020b361d22904695cab6b9a7c1ea50 /bitbake/bin | |
parent | 324c9fd666117afb0dd689eaa8551bb02d6a042b (diff) | |
download | poky-1effd1014d9140905093efe25eeefedb28a10875.tar.gz |
bitbake: hashserv: Add Unihash Garbage Collection
Adds support for removing unused unihashes from the database. This is
done using a "mark and sweep" style of garbage collection where a
collection is started by marking which unihashes should be kept in the
database, then performing a sweep to remove any unmarked hashes.
(Bitbake rev: 433d4a075a1acfbd2a2913061739353a84bb01ed)
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/bin')
-rwxr-xr-x | bitbake/bin/bitbake-hashclient | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/bitbake/bin/bitbake-hashclient b/bitbake/bin/bitbake-hashclient index 2cb6338666..f71b87404a 100755 --- a/bitbake/bin/bitbake-hashclient +++ b/bitbake/bin/bitbake-hashclient | |||
@@ -195,6 +195,28 @@ def main(): | |||
195 | columns = client.get_db_query_columns() | 195 | columns = client.get_db_query_columns() |
196 | print("\n".join(sorted(columns))) | 196 | print("\n".join(sorted(columns))) |
197 | 197 | ||
198 | def handle_gc_status(args, client): | ||
199 | result = client.gc_status() | ||
200 | if not result["mark"]: | ||
201 | print("No Garbage collection in progress") | ||
202 | return 0 | ||
203 | |||
204 | print("Current Mark: %s" % result["mark"]) | ||
205 | print("Total hashes to keep: %d" % result["keep"]) | ||
206 | print("Total hashes to remove: %s" % result["remove"]) | ||
207 | return 0 | ||
208 | |||
209 | def handle_gc_mark(args, client): | ||
210 | where = {k: v for k, v in args.where} | ||
211 | result = client.gc_mark(args.mark, where) | ||
212 | print("New hashes marked: %d" % result["count"]) | ||
213 | return 0 | ||
214 | |||
215 | def handle_gc_sweep(args, client): | ||
216 | result = client.gc_sweep(args.mark) | ||
217 | print("Removed %d rows" % result["count"]) | ||
218 | return 0 | ||
219 | |||
198 | parser = argparse.ArgumentParser(description='Hash Equivalence Client') | 220 | parser = argparse.ArgumentParser(description='Hash Equivalence Client') |
199 | parser.add_argument('--address', default=DEFAULT_ADDRESS, help='Server address (default "%(default)s")') | 221 | parser.add_argument('--address', default=DEFAULT_ADDRESS, help='Server address (default "%(default)s")') |
200 | parser.add_argument('--log', default='WARNING', help='Set logging level') | 222 | parser.add_argument('--log', default='WARNING', help='Set logging level') |
@@ -274,6 +296,19 @@ def main(): | |||
274 | db_query_columns_parser = subparsers.add_parser('get-db-query-columns', help="Show columns that can be used in database queries") | 296 | db_query_columns_parser = subparsers.add_parser('get-db-query-columns', help="Show columns that can be used in database queries") |
275 | db_query_columns_parser.set_defaults(func=handle_get_db_query_columns) | 297 | db_query_columns_parser.set_defaults(func=handle_get_db_query_columns) |
276 | 298 | ||
299 | gc_status_parser = subparsers.add_parser("gc-status", help="Show garbage collection status") | ||
300 | gc_status_parser.set_defaults(func=handle_gc_status) | ||
301 | |||
302 | gc_mark_parser = subparsers.add_parser('gc-mark', help="Mark hashes to be kept for garbage collection") | ||
303 | gc_mark_parser.add_argument("mark", help="Mark for this garbage collection operation") | ||
304 | gc_mark_parser.add_argument("--where", "-w", metavar="KEY VALUE", nargs=2, action="append", default=[], | ||
305 | help="Keep entries in table where KEY == VALUE") | ||
306 | gc_mark_parser.set_defaults(func=handle_gc_mark) | ||
307 | |||
308 | gc_sweep_parser = subparsers.add_parser('gc-sweep', help="Perform garbage collection and delete any entries that are not marked") | ||
309 | gc_sweep_parser.add_argument("mark", help="Mark for this garbage collection operation") | ||
310 | gc_sweep_parser.set_defaults(func=handle_gc_sweep) | ||
311 | |||
277 | args = parser.parse_args() | 312 | args = parser.parse_args() |
278 | 313 | ||
279 | logger = logging.getLogger('hashserv') | 314 | logger = logging.getLogger('hashserv') |