Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider using the indextree crate to implement Huffman trees #28

Open
AlexTMjugador opened this issue Apr 3, 2023 · 1 comment
Open
Assignees
Labels
enhancement New feature or request

Comments

@AlexTMjugador
Copy link
Member

AlexTMjugador commented Apr 3, 2023

Currently, OptiVorbis implements Huffman tree operations using the ouroboros and bumpalo crates. This works fine, but profiling showed that walking through Huffman trees is a hot operation during optimization, responsible for most of the execution time. Therefore, as highlighted by Amdahl's law, optimizing the runtime of this operation is crucial to increase the overall performance of OptiVorbis.

One possible avenue of optimization is to use the indextree crate instead of the two previously mentioned. The basic idea is to use it to store indexes instead of pointers to children in the tree nodes, potentially making it easier for the Rust compiler to choose to use a more efficient base + index addressing mode in the emitted assembly instructions rather than resorting to dereferencing a generic reference. Even if this change does not improve performance, it would remove one dependency and likely simplify the code, which is welcome anyway.

Some basic benchmarks should be added to the codebase to assess the performance impact of this change.

@AlexTMjugador AlexTMjugador added the enhancement New feature or request label Apr 3, 2023
@AlexTMjugador AlexTMjugador self-assigned this Apr 3, 2023
@AlexTMjugador
Copy link
Member Author

Perhaps more importantly than the likely insignificant performance changes, ouroboros pulls in a lot of dependencies, is directly or indirectly responsible for ≈10% of the total OptiVorbis crate build time (checked with cargo build --timings -p optivorbis), and has caused security issues in the past.

Ouroboros dependency tree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

1 participant