Skip to content

fix: cache asset hashes across repeated segments - #156

Merged
renezander030 merged 1 commit into
masterfrom
fix/155-cache-asset-hashes
Oct 19, 2026
Merged

renezander030 merged 1 commit into
masterfrom
fix/155-cache-asset-hashes

Conversation

@renezander030

Copy link
Copy Markdown
Owner

Every segment after the first re-hashes both the original media and its staged copy. A long cut list therefore reads entire multi-GB files dozens of times during compile, add-video, and add-audio.

Cache each file's SHA-1 digest within the process, keyed by its absolute path and validated against its device, inode, size, and nanosecond modification/change timestamps. Keep at most 256 recently used digests. Both equality checks and collision filename generation reuse these digests, while occupied collision candidates are still checked against their actual content.

In the regression with 40 cuts per source, full-file hash reads fall from 78 to 2 per source (39x fewer bytes read for hashing). The test compiles both video and audio and checks every segment's source offset, target start, asset reference, and copied bytes. Additional tests cover occupied hash suffixes, relative paths, edited source/destination files, same-size edits with restored mtime, replacement files, and deleted/recreated assets. The three read-count regressions fail against the unchanged implementation and pass with this patch.

Validation:

  • npm test on Node 20: fresh TypeScript build; 1,262 passed, one platform-specific skip, zero failures.
  • npm run lint: 210 files checked, clean.
  • python3 -m unittest discover -s python/tests -v: 19 passed.
  • CI's Wasm build, parity tests, zero-import component verification, dependency audit, and checksum-pinned Wassette MCP smoke check run during Pulse staging and again on publication.

The optional npx --yes @reneza/skillgate audit passed its instruction-sync, stray-TODO, and secret checks, but its built-in test gate timed out after 30 seconds on rio. The direct full test command and repository pre-commit hook run without that audit limit.

The measured improvement is in bytes read for hashing on Linux; no Windows wall-clock benchmark is claimed. No new dependencies or version bump.

Closes #155.

@renezander030
renezander030 enabled auto-merge (squash) October 19, 2026 09:04
@renezander030
renezander030 merged commit a9cd348 into master Oct 19, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

compile: every segment of the same source re-hashes the full media file twice (hundreds of GB read for long videos)

1 participant