I was curious this weekend about how MD5 vs SHA-1 vs SHA-256 performance stacks up. If you have the OpenSSL libraries installed, you can run a short test to calculate performance on your CPU. It gives ballpark estimates, which may or may not carry over to real-world performance on actual file data.
$ openssl speed md5 sha1 sha256
Estimates/Summary:
SHA-1 is about 55-75% the speed of MD5
SHA-256 is about 25-40% the speed of MD5
SHA-256 is about 50-60% the speed of SHA-1
Whether or not you will be CPU-bound in computing the file hashes will depend on where you are reading the files from. Over gigabit LAN or from older mechanical hard drives, or external USB2/USB3 drives, most modern CPUs can keep up even with SHA-256. But if you are reading the files off of a local SSD or really fast mechanical drive (or RAID) then you are likely to be bottlenecked by the CPU.
Details (openssl test):
AMD Opteron 2210 HE @ 1.8GHz
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
md5 25350.32k 80336.17k 191208.72k 295806.29k 353239.04k
sha1 27497.51k 77933.74k 168168.28k 235850.41k 268205.53k
sha256 22543.94k 51445.66k 88818.90k 108275.37k 116416.81k
AMD Opteron 6212 @ 2.6GHz
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
md5 45318.86k 134308.27k 324486.83k 493194.58k 582216.36k
sha1 47027.79k 128927.42k 278593.02k 410244.44k 471425.02k
sha256 28690.18k 62662.12k 106333.61k 127998.98k 136325.80k
AMD Opteron 1214 @ 2.2GHz
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
md5 30417.85k 96951.65k 235868.24k 361845.33k 433094.16k
sha1 34126.39k 98072.04k 208456.70k 291041.35k 328654.85k
sha256 27362.92k 63127.50k 108537.35k 132564.38k 142727.86k
AMD Opteron 4180 @ 2.6GHz
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
md5 43180.73k 129437.27k 298339.15k 442248.19k 519602.18k
sha1 45699.96k 123160.41k 255322.20k 347329.88k 390250.50k
sha256 33757.18k 75191.85k 128929.37k 157659.82k 168790.70k
Intel Xeon E5520 @ 2.27GHz
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
md5 25945.50k 88897.43k 220292.01k 354356.91k 430339.41k
sha1 26568.69k 78716.78k 174506.35k 251495.08k 288858.11k
sha256 20495.77k 49206.73k 90735.59k 114904.75k 124605.78k
AMD Phenom II X4 810 @ 2.6GHz
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
md5 42430.27k 130101.07k 301091.11k 444996.84k 522918.05k
sha1 46015.86k 125298.40k 256391.07k 349968.95k 393227.03k
sha256 34432.84k 76378.03k 130828.67k 158859.76k 168782.78k
Additional tests/experiments:
Tests using "(sha256|sha1|md5)sum" programs on Opteron 4180 w/ SSDs, using 133GB of large files. The CPU core assigned to the task was pegged at 100% utilization according to "atop". The SSD used has an estimated top speed of 490 MB/s.
MD5: ~318 MiB/s (428 sec)
SHA-1: ~187 MiB/s (729 sec) - 1.7x slower then MD5
SHA-256: ~113 MiB/s (1204 sec) - 2.8x slower then MD5, 1.65x slower then SHA-1
No comments:
Post a Comment