🧱 Chunk is a download manager for slow and unstable servers

Progress file is rewritten in full on every chunk: O(n^2) write amplification #14

Open cuducos.me
Open opened by cuducos.me

Problem

Each done rewrites the entire gob of all chunks under a mutex (progress.go:108-129). At 5 GB with the default 8 KiB chunk size that is 655K chunks → roughly 1.7 TB of progress-file writes per download, and the mutex serializes it against the 8 concurrent chunk writers.

Impact

Progress persistence dominates the runtime for large files, and per-call cost grows with the number of chunks.

Measured

~433 µs per call at 10K chunks (package-copy benchmark).

Suggested fix

Write a fixed-size bitmap in place, or batch persistence every N chunks.

Sign up or Sign in to add to the discussion.