Repository navigation
manifest: reuse the input buffer while hashing a file - #4941
Brandon-C-Wheeler wants to merge 1 commit into
Conversation
|
Tested 4e45aca on Arch Linux (in a VM), CPython 3.14: pass.
|
|
PASS. The claim reproduces: the 32 MiB hash peak drops from 16.78 MB to 8.39 MB under Only nit: Approve. AI-assisted review, no game files, no GPU. |
|
Independent Windows check at Environment: Windows 11 x64, CPython 3.13.7, Tests:
Peak Python allocation,
Both produced the same four SHA-256 digests and sizes; the manifest bytes differ only in the Negative control: with only the updated test file copied onto the parent,
|
|
Independent check of Environment: Windows 11, CPython 3.15.2, CPU only. Synthetic manifest trees, no GPU, no game files.
Diff reuses one read buffer across a file's hash chunks instead of allocating per chunk — same bytes hashed, less churn. Matches the title. AI-assisted (Devin). |
Fixes #4922. Coordination claim.
What and why
When a hash worker asks for the next 8 MiB chunk, its previous chunk is still live. The manifest tool now allocates one buffer per open file, capped at 8 MiB, and fills it with
readinto. Each SHA-256 update consumes exactly the bytes read, including after a short read. The regression exercises multiple short reads and a partial final chunk using the same buffer.Measured on Windows 11 x64
Median peak Python allocations measured with
tracemallocon CPython 3.14.0. Each run hashed four synthetic 32 MiB files. Each worker count and revision ran in three fresh processes, with file creation outside the measurement.Every run returned the expected sizes and SHA-256 digests. Through the CLI, the patched four-worker verifier accepted the manifest created by the original serial tool, and the original verifier accepted the patched tool’s manifest.
Tests
python -I -m unittest discover -s tests -p "test_manifest*.py"— 75 passed, 3 skipped.python -I tests/test_manifest.py— 36 passed, 1 skipped.#4918 adds an EOF check immediately after the same loop. I tested the two changes together at
077bda2b, resolving the adjacent hunk by keeping this loop and #4918’s EOF check. On Windows, 39 manifest tests passed and 1 skipped in that combination.AI-assisted with Codex. Tests and measurements used synthetic files.