Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion internal/par2/par2.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,13 @@ func (p *NativeExecutor) CreateInDirectory(ctx context.Context, files []fileinfo
// createPar2ForFile creates PAR2 files for a single input file in the given directory.
func (p *NativeExecutor) createPar2ForFile(ctx context.Context, file fileinfo.FileInfo, dirPath string) ([]string, error) {
var parBlockSize uint64
if p.cfg.SliceSize > 0 {
if p.cfg.SliceSize > 0 && uint64(p.cfg.SliceSize) <= file.Size {
parBlockSize = uint64(p.cfg.SliceSize)
} else {
// Configured SliceSize exceeds file size (or is unset): fall back to
// article-size-based calculation. Clamping SliceSize to ≈file.Size
// creates only 1-2 slices with a nearly-zero last slice, which triggers
// undefined behavior in the ParPar C SIMD backend on Linux x86_64 (AVX-512).
parBlockSize = calculateParBlockSize(file.Size, p.articleSize)
}
// Guard: block size must not exceed file size AND must be SIMD-aligned.
Expand Down
Loading