Skip to content

[x86_64] Assembly version of MD5Transform added to hash package

Summary

This merge, building on !486 (merged), provides an x86_64 assembly-optimised version of the MD5 hash function in the hash package. Two versions of MD5Transform are provided... a regular x86-64 assembly language version, and a version that makes use of the ANDN operation, which requires the target processor to support BMI1.

What is the current bug behavior?

N/A

What is the behavior after applying this patch?

Two new assembly versions of the MD5 algorithm that should be significantly faster than the Pascal fallback, as well as providing cleaner expansion options for other platform-specific implementations.

Relevant logs and/or screenshots

Speed increases under x86_64-win64:

MD5 of a million "a" symbols

Average time taken = 1.678 ms (Trunk)
Average time taken = 1.665 ms (Merge request !486)
Average time taken = 1.660 ms (Merge request !486 with BMI1 (using "-CpCOREAVX2" option))
Average time taken = 1.233 ms (optimised x86_64 assembly)
Average time taken = 1.167 ms (optimised x86_64 assembly with BMI1)

Additional Notes

The md5performancetest project under packages/hash/examples has been adjusted to provide better granularity in the timing measurement (before, its precision was rounded down to the nearest second - now it's down to the nearest millisecond).

While MD5 is cryptographically broken, it is still widely used as a checksum, so it makes sense to provide a fast implementation.

Merge request reports