这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@folkertdev
Copy link
Member

When you finally spot the thing... 🤦 we are now faster than zlib-ng for all chunk sizes.

chart (5)

It's only a marginal improvement for chunk size 2**4, but quite significant for what are probably the most common chunk sizes (very small chunk sizes likely indicate io-bound operation).

chart (6)


After fixing the bug of exiting the loop too early (first commit), I then made the bound a bit more accurate, and finally refactored the output type of len_and_friends. The final commit has no performance impact.

@folkertdev folkertdev requested a review from bjorn3 December 9, 2024 18:14
@codecov
Copy link

codecov bot commented Dec 9, 2024

Codecov Report

Attention: Patch coverage is 76.66667% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
zlib-rs/src/inflate.rs 74.07% 7 Missing ⚠️
Files with missing lines Coverage Δ
zlib-rs/src/inflate/bitreader.rs 91.04% <100.00%> (+0.20%) ⬆️
zlib-rs/src/inflate.rs 91.05% <74.07%> (-0.19%) ⬇️

... and 3 files with indirect coverage changes


#[inline(always)]
pub fn bytes_remaining_including_buffer(&self) -> usize {
(self.end as usize - self.ptr as usize) + (self.bits_used as usize >> 3)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Using / 8 instead of >> 3 may be a bit clearer and will optimize to the same assembly.

Copy link
Member Author

Choose a reason for hiding this comment

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

we can make a pass over the repo at some point. I think zlib-ng never updated this, and the original zlib that it forked was written at a time when apparently that optimization was not (effectively) guaranteed.

Copy link
Collaborator

@bjorn3 bjorn3 left a comment

Choose a reason for hiding this comment

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

Nice!

@folkertdev folkertdev merged commit afcf420 into main Dec 10, 2024
20 checks passed
@folkertdev folkertdev deleted the fix-fast-loop-bound branch December 10, 2024 09:04
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