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

Use generics for bit depth throughout the encoder #3121

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

shssoichiro
Copy link
Collaborator

This is a followup from #3116 which expands this optimization to as many places in the encoder as we can reasonably utilize it. By using generics, there are places where the compiler is able to simplify math operations at compile time as well as areas where the compiler is able to remove branches so that we only branch on bit depth at the highest level of the code (and therefore the fewest number of times).

Based on hyperfine benchmarking, this results in a 1-2% speedup across the encoding process, although it does increase the final binary size.

This is a followup from xiph#3116 which expands this optimization
to as many places in the encoder as we can reasonably utilize it.
By using generics, there are places where the compiler is able to
simplify math operations at compile time as well as areas where the
compiler is able to remove branches so that we only branch on bit depth
at the highest level of the code (and therefore the fewest number of
times).

Based on hyperfine benchmarking, this results in a 1-2% speedup across
the encoding process, although it does increase the final binary size.
@lu-zero
Copy link
Collaborator

lu-zero commented Feb 1, 2023

Looks like arm needs some additional changes.

Could you mention the the amount of size increase?

@shssoichiro
Copy link
Collaborator Author

On a fully stripped binary on x64 linux, before was 3.8mb and after was 5.1mb

@lu-zero
Copy link
Collaborator

lu-zero commented Feb 6, 2023

Let's try to do that in steps and measure the increase.

@barrbrain
Copy link
Collaborator

I have considered creating an internal enum for bit-depth, with access to the related values when needed.
This would allow us to at least restrict some of the branching and hint about the value range,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants