M4B audiobook parsing improvements#316
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves M4B/MP4 audiobook probing performance for large files by adding bounded intra-file concurrency when fetching scattered chapter-title samples, and fixes an S3 range-read bug in the fetcher layer.
Changes:
- Thread a
concurrencysetting fromAudioParserthrough probing to MP4 chapter extraction to parallelize scattered chapter-title reads. - Implement concurrent, coalesced MP4 chapter-title sample fetching using
errgroupwith a configurable limit. - Fix
s3Resource.Readto actually send the constructedGetObjectInput(including theRangeheader), and add tests to verify ranged vs whole-object reads.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/parser/audio/rich.go | Passes parser concurrency into per-item probing. |
| pkg/parser/audio/probe.go | Threads concurrency into MP4 probing path. |
| pkg/parser/audio/parser.go | Clarifies concurrency semantics (file-level and intra-file). |
| pkg/parser/audio/mp4.go | Adds concurrent chapter-title sample fetching with bounded parallelism. |
| pkg/fetcher/fetcher_s3.go | Fixes S3 ranged reads by using the request object with Range applied. |
| pkg/fetcher/fetcher_s3_test.go | Adds coverage to assert correct S3 range-header behavior and response slicing. |
| pkg/fetcher/fetcher_file.go | Makes file-backed resources safer for concurrent ranged reads (ReadAt/SectionReader) and serializes offset-based reads. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.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.
This is a follow-up to the audiobook parsing that was implemented. Some weak points were identified after testing it, in particular with large .m4b files. More concurrency is now used to load the TOC of such files more quickly.
A bug was also found in the file fetcher
(Most changes by Claude Fable)