-
Notifications
You must be signed in to change notification settings - Fork 15
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
Implement generic CRC-32 #24
Implement generic CRC-32 #24
Conversation
72d4279
to
390d0e1
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #24 +/- ##
==========================================
+ Coverage 77.64% 85.99% +8.35%
==========================================
Files 28 29 +1
Lines 6388 6591 +203
==========================================
+ Hits 4960 5668 +708
+ Misses 1428 923 -505 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left some comments.
For usage in the gzip logic it's important to have a function that can take in an existing checksum value and more bytes, and update the checksum with those bytes. It's not obvious how this implementation would do that to me (but hopefully that is simple to add?)
also as a general observation this already seems bigger and more complex than what https://github.com/srijs/rust-crc32fast/blob/master/src/baseline.rs is quite simple to follow. Am I missing something that is implemented here but not there (besides the tables, which apparently should preferably be stored in a static, not a const srijs/rust-crc32fast@e61ce6a I did not know this, but that is useful information). |
Should be pretty simple, we can replace |
That should be pretty simple to add by using the tables from |
In that case I think it makes more sense to follow the zlib-ng implementation more closely (https://github.com/zlib-ng/zlib-ng/blob/develop/arch/generic/crc32_braid_c.c). it seems to have diverged somewhat from the original paper. This is often my experience with CS literature: the way to write something up for an academic paper is generally not how you actually implement things. It will be interesting to see how this compares to the The implementation in that C file seems straightforward, but we can probably clean it up given that we're using rust. But I think it's a good idea to use the same name (braid), type signature, and generally follow its structure. I think using an array for the There is some arithmetic with using macros to unroll without duplicating too much code is fine (our adler32 implementation does this too). |
33a1230
to
5bec7b6
Compare
Add a naive implementation of CRC-32 based on the C code from the PNG specification. Add an optimized word-size implementation based on Kadatch and Jenkins. Add optimized interleaved implementation from section 4.11 of the same paper.
5bec7b6
to
25708f1
Compare
could you add some I've been playing around with the simd version, and from what I see
But that benchmark measures performance when all the data is available. Zlib can en/decode in a streaming fashion, and the crc32 algorithm it uses is tuned for that: Also we do need the fused crc with memcpy, and I don't think that fits into the current With all that, if you want to make more open source contributions, I think you all have a better setup for running avx-512 SIMD code, so you might look into adding a 512-bit simd version based on https://github.com/zlib-ng/zlib-ng/blob/develop/arch/x86/crc32_fold_vpclmulqdq_tpl.h to crc32fast itself. Assuming our code will be close to what |
hah, wow
that makes a big difference! This is running
and the equivalent thing for the zlib-ng approach. So, that is something that we might also consider upstreaming after we've cleaned it up considerably (the crc32fast code looks a lot nicer than the zlib-ng version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for implementing this!
I'll just fix the clippy issues on main.
Most of the clippy issues should go away once another part of the code starts using these functions. |
Add a naive implementation of CRC-32 based
on the C code from the PNG specification.