digest-crc icon indicating copy to clipboard operation
digest-crc copied to clipboard

Would it make sense to have comparative benchmarks against other digests?

Open yxhuvud opened this issue 2 years ago • 3 comments

Would it make sense to have benchmarks for one or a few of the ruby built in digests as well, so that there is some ballpark comparison number?

yxhuvud avatar Mar 16 '23 14:03 yxhuvud

Interesting idea. I guess it could show that Digest::CRC* isn't any slower than Digest::MD5, etc, which are implemented by libssl. Although, I would wager the CRC algorithms will be faster than other cryptographic digests, since CRC has less arithmetic operations. I also do not want to potentially encourage people to use CRC digests instead of cryptographic hashes (which should guarantee no collisions), just because CRC is simply faster.

postmodern avatar Mar 17 '23 04:03 postmodern

Right. Though as md5 is not secure anymore, that should be fine. I tried to just add Digest::MD5 to the benchmark script, but the results surprised me as md5 seems faster. I wonder if someone spent way too much time optimizing that one..

yxhuvud avatar Mar 18 '23 16:03 yxhuvud

The simple lookup table algorithm used in digest-crc is not very fast for modern general-purpose processors. Faster ones are in practical use.

For information:


My crc-turbo uses the "Slicing by 16" variant, but the zlib crc32() built into FreeBSD is about 1.6 times faster. Also, lzma_crc64() by liblzma is about 3.6 times faster than my crc-turbo.

:thinking: I may write an acceleration patch for digest-crc. However, I cannot handle CLMUL extension instructions, so it will be equivalent to "Slicing by 16" or "Slicing by 8".

dearblue avatar Jul 01 '23 11:07 dearblue