Consider using the indextree
crate to implement Huffman trees
#28
Labels
enhancement
New feature or request
indextree
crate to implement Huffman trees
#28
Currently, OptiVorbis implements Huffman tree operations using the
ouroboros
andbumpalo
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.
The text was updated successfully, but these errors were encountered: