mirror of
https://github.com/xcat2/confluent.git
synced 2026-08-03 16:07:00 +00:00
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.
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user