perf(download): add minChunkSize heuristic to optimize worker count #163
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
thwap/pget!163
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/optimize-chunk-size"
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?
What
Add
minChunkSize(1MB) heuristic to avoid creating excessively small chunks when concurrency is high relative to file size.Why
With
-n 10on a 5MB file, each chunk would be ~500KB — the HTTP request overhead dominates the transfer time. The heuristic caps effective concurrency so each chunk is at least 1MB.Implementation
minChunkSize = 1 << 20(1MB) constantDownload(), whenfileSize / chunkCount < minChunkSize, reducechunkCountto the nearest value keeping chunks ≥ 1MBadjusted workers from 10 to 5 (min chunk size 1.0MB)Testing
-n 10logsadjusted workers from 10 to 5-n 10— no adjustment (chunks are 1GB each)go test -race ./...— all passgo build ./...,go vet ./...,golangci-lint run— all cleanBreaking Changes
None — only reduces workers below the user's requested count when chunks would be too small.
Closes #118, #117
Review: APPROVED
Verification
go vet ./...— ✅ passesgo build ./...— ✅ passesgo test -race ./...— ✅ all passChanges
internal/downloader/download.go—minChunkSize = 1MBconstant; decrements chunkCount until each chunk ≥ 1MB; verbose log on adjustmentBehavior
-n 10→ workers adjusted to 5 (1MB chunks)-n 10→ no adjustment (1GB chunks)Closes #116, #117, #118 on merge.