Heuristic:0xsline OpenChatCut Large File Hash Skip
| Knowledge Sources | |
|---|---|
| Domains | Optimization, Media_Processing |
| Last Updated | 2026-10-22 14:00 GMT |
Overview
Skip full-file SHA-256 content hashing for media files above 1.5 GiB to avoid I/O saturation during import.
Description
When importing local media, OpenChatCut computes a SHA-256 content hash for deduplication. For files larger than 1.5 GiB, the hash is skipped entirely (empty string returned) because the second pass over multi-GiB masters costs more in disk I/O than content-addressed dedup can save. The import pipeline already saturates disk I/O with hash + normalize + ASR. Skipping the hash on large files lets those downstream stages proceed without redundant reads.
Usage
Use this heuristic when importing large media files (video masters, long recordings). Apply it when disk I/O is the bottleneck and the deduplication benefit of hashing a multi-GiB file is outweighed by the time to read it a second time. The trade-off is that large duplicate files will not be detected by content hash.
The Insight (Rule of Thumb)
- Action: Compare `sourceInfo.size` against `LARGE_HASH_SKIP_BYTES` (1.5 GiB). If larger, return empty hash string instead of computing SHA-256.
- Value: Threshold = 1.5 * 1024 * 1024 * 1024 bytes (1,610,612,736 bytes).
- Trade-off: Large duplicate files are not detected by content hash; dedup falls back to filename/size matching only.
- Compatibility: Hash-based dedup still works for all files under the threshold.
Reasoning
The import pipeline performs hash + normalize + ASR sequentially, each reading the full file. A multi-GiB video master takes seconds to minutes to hash, and the deduplication benefit is marginal — large files are rarely exact duplicates. The 1.5 GiB threshold balances the cost of a full file read against the probability of finding a duplicate. The `stat` call before and after hashing also detects if the source file changed during import (TOCTOU guard).