Skip to content

Tune flow of inline methods in symbol_with_update - #2671

Merged
barrbrain merged 1 commit into
xiph:masterfrom
barrbrain:ec-no-panic
Feb 15, 2021
Merged

Tune flow of inline methods in symbol_with_update#2671
barrbrain merged 1 commit into
xiph:masterfrom
barrbrain:ec-no-panic

Conversation

@barrbrain

Copy link
Copy Markdown
Collaborator
  • Mostly avoid calling Vec::reserve() in CDFContextLogOps::push().
  • Manually elide bounds checks in WriterBase::symbol() as they are not easily inferred by the compiler although statically known.
  • Rewrite ec::rust::update_cdf() to be panic-free and hint to the compiler not to unroll beyond the maximum CDF length.

@lu-zero lu-zero left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine, if you could address the 2 nits on landing would be nice.

Comment thread src/ec.rs
@@ -524,9 +524,12 @@ where
#[inline(always)]
fn symbol(&mut self, s: u32, cdf: &[u16]) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a TODO: rewrite once const generics are stable

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the scope of rewriting using const generics much broader than this function?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but this is one that would be good to not forget :)

Comment thread src/ec.rs Outdated
}
// Single loop (faster)
for (i, v) in cdf[..nsymbs - 1].iter_mut().enumerate() {
for (i, v) in cdf[..nsymbs - 1].iter_mut().enumerate().take(15) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

15 shouldn't be expressed using Self::CDF_LEN_MAX ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self::CDF_LEN_MAX is defined for CDFContextLogOps rather than WriterBase. We could reference context::CDF_LEN_MAX after making it accessible.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably it would be good or having ec::CDF_LEN_MAX defined.

* Mostly avoid calling Vec::reserve() in CDFContextLogOps::push().
* Manually elide bounds checks in WriterBase::symbol() as they are
  not easily inferred by the compiler although statically known.
* Rewrite ec::rust::update_cdf() to be panic-free and hint to the
  compiler not to unroll beyond the maximum CDF length.
@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Status

Coverage increased (+1.5%) to 83.026% when pulling e9be6c9 on barrbrain:ec-no-panic into 1869a8b on xiph:master.

@barrbrain
barrbrain merged commit e9be6c9 into xiph:master Feb 15, 2021
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