mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:00:52 +01:00
[PR #129] [MERGED] manifest: hash through one reused buffer, halving peak chunk memory per worker (OLD-4922) #181
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#181
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/129
Author: @natterman12
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @ubiquitarianism
Base:
main← Head:manifest/reuse-hash-buffer📝 Commits (1)
9541c00manifest: hash through one reused buffer, halving peak chunk memory per worker (OLD-4922)📊 Changes
2 files changed (+53 additions, -9 deletions)
View changed files
📝
tests/test_manifest.py(+43 -6)📝
tools/manifest.py(+10 -3)📄 Description
Claimed in the coordination issue as: OLD-4922 (#14; old issue "manifest: reuse the hash input buffer to halve peak chunk memory per worker", indexed in #18)
What and why
tools/manifest.py,_hash_file()read the file withf.read()allocates the next 8 MiBbytesobject whilechunkstill refers to the last one, so each hashing worker holds two chunks at its peak. With--jobs Nthat is 16 MiB times N for the read buffers alone.It now fills one
memoryview-backedbytearraywithreadinto(), the waymanifest_verifier.sha256_file()already does. Sizes, digests, the manifest format and the three change-during-hashing checks are unchanged.Measured
tracemallocpeak of one_hash_file()call on a 320 MiB temporary file (synthetic bytes, Windows 11, Python 3.15.2, NVMe):The throughput difference is within what I would expect from run-to-run noise on a warm cache; I am only claiming the memory figure.
Tested
No GPU involved. Windows 11, Python 3.15.2:
python -I tests/test_manifest.py: OK, 39 tests (1 skipped, as onmain)python -I tests/test_manifest_verifier.py,test_text_write_line_endings.py,test_text_encoding.py: OKtest_hashing_reuses_one_chunk_buffer: six 1 MiB chunks plus a partial one must hash correctly with a peak under 1.5 chunks. It fails onmain(peak 2,098,046 bytes for a 1,048,576-byte chunk).test_hashing_follows_short_reads: areadinto()that returns 7 bytes at a time still hashes every byte once.test_same_size_change_during_read_keeps_the_previous_manifest: it hookedstream.read, which the tool no longer calls, so it now hooksstream.readinto. Same edit, same expectedManifestError.AI-assisted: yes (Claude Code)
Checklist
docs/design.md, with how it was confirmed. (not applicable: no translator change)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.