Files
romm/backend/utils
Spinnich abade695c7 perf(scan): read files in 256 KiB chunks instead of 8 KiB
Hashing runs in threads via asyncio.to_thread, and hashlib/zlib release
the GIL per chunk. At 8 KiB the threads hand the GIL back so often that
concurrent scans contend rather than overlap, which capped scan
concurrency and made high worker counts actively harmful.

Hashing 1.96 GiB of real ROM files at 8 workers goes from 154 MiB/s to
666 MiB/s (4.3x). Single-worker throughput is unchanged (108 vs 114
MiB/s), so this is not read-syscall overhead; it only bites under
concurrency. 256 KiB is the knee, 1 MiB measured no better.

The chunk bounds a streaming read, so peak memory is one chunk per
in-flight file, a few MiB at any realistic worker count.

Digests are unaffected: all 67 files in the test library produce
byte-identical crc/md5/sha1 at 8 KiB, 64 KiB, 256 KiB and 1 MiB.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 17:55:19 +00:00
..
2025-09-04 11:17:00 -03:00
2026-08-01 14:52:55 -04:00
2026-06-28 21:48:50 -04:00
2026-07-06 22:17:56 -04:00