perf(parser): 4 targeted optimizations for NZB import pipeline#347
Merged
perf(parser): 4 targeted optimizations for NZB import pipeline#347
Conversation
- Parallelize yEnc header fetches (2nd + last segment) in normalizeSegmentSizesWithYenc using errgroup.WithContext, cutting normalization wall time ~50% for files with 3+ segments - Pre-compile 4 obfuscation regex patterns in fileinfo as package-level vars, eliminating sync.Map lookups on every filename evaluation - Consolidate 4 binary.Read calls in PAR2 ReadFileDescriptor into a single fixed-struct read (56 bytes in one shot) - Replace 8-byte loop in HasMagicBytes with bytes.Equal for SIMD-backed comparison, consistent with fileinfo/detector.go style Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
drondeseries
referenced
this pull request
in drondeseries/altmount_old
Apr 16, 2026
- Parallelize yEnc header fetches (2nd + last segment) in normalizeSegmentSizesWithYenc using errgroup.WithContext, cutting normalization wall time ~50% for files with 3+ segments - Pre-compile 4 obfuscation regex patterns in fileinfo as package-level vars, eliminating sync.Map lookups on every filename evaluation - Consolidate 4 binary.Read calls in PAR2 ReadFileDescriptor into a single fixed-struct read (56 bytes in one shot) - Replace 8-byte loop in HasMagicBytes with bytes.Equal for SIMD-backed comparison, consistent with fileinfo/detector.go style Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
normalizeSegmentSizesWithYenc: 2nd and last segment fetches now run concurrently viaerrgroup.WithContext— ~50% wall-time reduction per file with 3+ segmentsfileinfo/fileinfo.go: 4 patterns promoted to package-level*regexp.Regexpvars, eliminatingsync.Maplookups on every filename evaluation (called 3× per file)binary.Readcalls inpar2/reader.go: 4 separate reads of the 56-byte FileDescriptor header collapsed into a single fixed-struct readbytes.EqualinHasMagicBytes(par2/detector.go): replaces manual 8-byte loop with SIMD-backedbytes.Equal, consistent withfileinfo/detector.gostyleTest plan
go build ./internal/importer/parser/...passesgo test ./internal/importer/parser/...passes (all existing tests green)🤖 Generated with Claude Code