Optimize allocations during metadata extraction
@icbaker is already working on this.
Since Dec 4, 2024.
- Dominant language
- Java
- Stars
- 3k
- Forks
- 955
- Avg merge
- 12d 14h
- Merged PRs (30d)
- 2
Description
[REQUIRED] Use case description
My music app relies on ExoPlayer's exposed metadata parsing (MetadataRetriever) to do mass scans of music libraries.
However, there seems to be some poor memory use during certain parts of metadata extraction, with entire ID3 tags and vorbis comments being directly read into memory.
When my metadata system encounters large cover art data and generally large tags, these repeated allocations and copies often slow down the process due to the constant GCs required.
Proposed solution
Refactor the container extractors to minimize reading out data into memory until the actual tag data is needed. For example, Id3Decoder would read from an input stream up until the identified bound of the tag, rather than reading from an in-memory ByteArray. Using some kind of composable reader pattern could be helpful if data transformation is required.
Alternatives considered
Using another tagging library that allows me to stream in this data. I don't like the duplication of container parsing, but can tolerate it for efficiency.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.