Skip to content

Conversation

@cruzzil
Copy link
Contributor

@cruzzil cruzzil commented Jan 18, 2026

Split this into small-ish commits with self explanatory goals.

The first big commit 6e0047e is re-ordering the file to line up with the original C file. This just makes it really easy to compare 1 vs the other.

For assertions, do you want assert! or debug_assert! ?

@codecov
Copy link

codecov bot commented Jan 18, 2026

Codecov Report

❌ Patch coverage is 87.32394% with 45 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
lib/compress/huf_compress.rs 87.32% 45 Missing ⚠️
Flag Coverage Δ
test-aarch64-apple-darwin 32.93% <86.76%> (-0.03%) ⬇️
test-aarch64-unknown-linux-gnu 31.67% <86.76%> (-0.02%) ⬇️
test-i686-unknown-linux-gnu 31.72% <86.76%> (-0.03%) ⬇️
test-x86_64-unknown-linux-gnu 33.36% <86.76%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
lib/compress/huf_compress.rs 82.15% <87.32%> (+0.66%) ⬆️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@folkertdev folkertdev left a comment

Choose a reason for hiding this comment

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

Nice, yes this good to review, thanks.

Some minor things, but overall this looks good. Again for easier reviewing, github can't handle force pushes very well, so it's easier if you make changes in later commits. The one exception is maybe assert -> debug_assert which you might be able to amend without horrible rebase conflicts down the line. But a separate commit is fine for that too.

Comment on lines 47 to 48
assert!((align & (align - 1)) == 0); /* pow 2 */
assert!(align <= HUF_WORKSPACE_MAX_ALIGNMENT);
Copy link
Member

Choose a reason for hiding this comment

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

So what's fun is that the assertions in the zstd codebase are actually more like rust's debug_assert!: they don't get compiled into release binaries.

So please convert these to debug_assert!. We only figured this out later, so you might find stray assert!s still.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

HUF_flushBits(bitC, kFastFlush);
n -= kUnroll;
}
assert!(n % (2 * kUnroll) == 0);
Copy link
Member

Choose a reason for hiding this comment

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

we can use n.is_multiple_of(2 * kUnroll) here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

n is a c_int which doesn't have is_multiple_of. I didn't want to change the data type in this cleanup

Copy link
Member

Choose a reason for hiding this comment

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

Right, that wasn't implemented. This is a data point that it maybe should be though. Anyway, that's fine then.


const {
assert!(
::core::mem::size_of::<HUF_compress_tables_t>() + HUF_WORKSPACE_MAX_ALIGNMENT
Copy link
Member

Choose a reason for hiding this comment

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

I believe we just have size_of in scope unqualified (this is some sort of version/edition thing). If not, you can import it explicitly at teh top and these lines become a little shorter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done and did same for align_of

@folkertdev
Copy link
Member

Awesome, thanks!

@folkertdev folkertdev merged commit 5a485b3 into trifectatechfoundation:main Jan 18, 2026
19 checks passed
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.

2 participants