diff --git a/backend/utils/archives.py b/backend/utils/archives.py index 9fd3828da..f6dcb0070 100644 --- a/backend/utils/archives.py +++ b/backend/utils/archives.py @@ -61,7 +61,10 @@ CHD_V5_SHA1_LENGTH: Final = 20 # SHA1 is 20 bytes CHD_V5_VERSION: Final = 5 # CHD v5 identifier CHD_MIME_TYPE: Final = "application/x-mame-chd" -FILE_READ_CHUNK_SIZE = 1024 * 8 +# Hashing runs in threads, and hashlib/zlib release the GIL per chunk. Small +# chunks hand the GIL back so often that concurrent scans contend instead of +# overlapping; 256 KiB is where that stops costing throughput. +FILE_READ_CHUNK_SIZE = 1024 * 256 _MIME_DETECTOR = magic.Magic(mime=True) _MIME_DETECTOR_LOCK = threading.Lock()