From 1a9613f22ebc48b97f808108912c1b76110ac42c Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Mon, 27 Jul 2026 02:19:13 +0200 Subject: [PATCH] Hash profile files in larger chunks The asyncio port added an await between every 2048 byte read, which roughly doubled the cost of hashing. imgutil runs entire packed images through this, and the server pays it on rebase and media import. Read a megabyte per iteration instead. That still yields hundreds of times per gigabyte, so the event loop stays responsive, and sha512 is independent of the read size, so existing manifests remain valid. --- confluent_server/confluent/osimage.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/confluent_server/confluent/osimage.py b/confluent_server/confluent/osimage.py index 17d53c3a..33062708 100644 --- a/confluent_server/confluent/osimage.py +++ b/confluent_server/confluent/osimage.py @@ -1041,11 +1041,11 @@ def copy_file(src, dst): async def get_hash(fname): currhash = hashlib.sha512() with open(fname, 'rb') as currf: - currd = currf.read(2048) + currd = currf.read(1048576) await asyncio.sleep(0) while currd: currhash.update(currd) - currd = currf.read(2048) + currd = currf.read(1048576) await asyncio.sleep(0) return currhash.hexdigest()